php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81364 Segfault running PHPStan test suite with JIT enabled
Submitted: 2021-08-16 01:25 UTC Modified: 2021-08-16 10:20 UTC
From: smokey101stair at gmail dot com Assigned:
Status: Open Package: JIT
PHP Version: 8.1.0beta2 OS: Ubuntu 20.04/WSL2
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: smokey101stair at gmail dot com
New email:
PHP Version: OS:

 

 [2021-08-16 01:25 UTC] smokey101stair at gmail dot com
Description:
------------
PHP segfaults while running PHPStan testsuite with the JIT enabled.

PHP 8.1.0beta2 (cli) (built: Aug 15 2021 19:45:43) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.1.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.0beta2, Copyright (c), by Zend Technologies

opcache.enable_cli=1
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.jit=1255
opcache.jit_buffer_size=256M
memory_limit=-1

Steps to reproduce:
1) git clone -b jit --single-branch https://github.com/TRowbotham/phpstan-src.git
2) cd phpstan-src
3) composer update
4) make tests

Actual result:
--------------
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007f4efd8db859 in __GI_abort () at abort.c:79
#2  0x00007f4efd8db729 in __assert_fail_base (fmt=0x7f4efda71588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=0x7f4efa9d4621 "var_info & (1 << var_type)",
    file=0x7f4efa9d3240 "/home/trevor/.phpbrew/build/8.1.0beta2-debug/ext/opcache/jit/zend_jit_x86.dasc", line=14933,
    function=<optimized out>) at assert.c:92
#3  0x00007f4efd8ecf36 in __GI___assert_fail (assertion=0x7f4efa9d4621 "var_info & (1 << var_type)",
    file=0x7f4efa9d3240 "/home/trevor/.phpbrew/build/8.1.0beta2-debug/ext/opcache/jit/zend_jit_x86.dasc", line=14933,
    function=0x7f4efa9d7f30 <__PRETTY_FUNCTION__.28793> "zend_jit_fetch_indirect_var") at assert.c:101
#4  0x00007f4efa9766b8 in zend_jit_fetch_indirect_var (Dst=0x7ffd8c062128, opline=0x42a30328, var_type=0 '\000',
    var_info_ptr=0x7ffd8c0620a4, var_addr_ptr=0x7ffd8c062130, add_indirect_guard=true)
    at /home/trevor/.phpbrew/build/8.1.0beta2-debug/ext/opcache/jit/zend_jit_x86.dasc:14933
#5  0x00007f4efa9a0b8a in zend_jit_trace (trace_buffer=0x7ffd8c066550, parent_trace=0, exit_num=0)
    at ext/opcache/jit/zend_jit_trace.c:4444
#6  0x00007f4efa9b2f1a in zend_jit_compile_root_trace (trace_buffer=0x7ffd8c066550, opline=0x42a30578, offset=3168)
    at ext/opcache/jit/zend_jit_trace.c:6498
#7  0x00007f4efa9b4f21 in zend_jit_trace_hot_root (execute_data=0x7f4efaa18940, opline=0x42a30578)
    at ext/opcache/jit/zend_jit_trace.c:6991
#8  0x000000005040f5c7 in ?? ()
#9  0x0000000040855030 in ?? ()
#10 0x00007f4efaa185c0 in ?? ()
#11 0x0000000000000000 in ?? ()

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-16 10:20 UTC] nikic@php.net
The composer update step fails for me:

  Problem 1
    - phpstan/phpstan-deprecation-rules[dev-master, 0.12.6] require phpstan/phpstan ^0.12.60 -> found phpstan/phpstan[dev-master, 0.12.60, ..., 0.12.x-dev (alias of dev-master)] but these were not loaded, likely because it conflicts with another require.
    - phpstan/phpstan-deprecation-rules[0.12.3, ..., 0.12.4] require phpstan/phpstan ^0.12 -> found phpstan/phpstan[dev-master, 0.12.0, ..., 0.12.x-dev (alias of dev-master)] but these were not loaded, likely because it conflicts with another require.
    - phpstan/phpstan-deprecation-rules 0.12.5 requires phpstan/phpstan ^0.12.26 -> found phpstan/phpstan[dev-master, 0.12.26, ..., 0.12.x-dev (alias of dev-master)] but these were not loaded, likely because it conflicts with another require.
    - phpstan/phpstan-deprecation-rules 0.12.x-dev is an alias of phpstan/phpstan-deprecation-rules dev-master and thus requires it to be installed too.
    - Root composer.json requires phpstan/phpstan-deprecation-rules ^0.12.3 -> satisfiable by phpstan/phpstan-deprecation-rules[0.12.3, ..., 0.12.x-dev (alias of dev-master)].
 [2021-08-16 19:07 UTC] smokey101stair at gmail dot com
I have updated the branch to include the vendor directory, so please try again after pulling the updates or re-cloning the branch. These updates also include some #[\ReturnTypeWillChange] additions to some of the files in the vendor directory to get vendor/bin/phpunit to run to completion, so don't use composer.

Updated steps to reproduce:
1) git clone -b jit --single-branch https://github.com/TRowbotham/phpstan-src.git
2) cd phpstan-src
3) Run "make tests" using a non-debug build of 8.1.0beta2. This will cause an error "Fatal error: Class "PHPUnit\Framework\TestFailure" not found"
4) Run "make tests" again. This time it will segfault; you are free to switch to a debug build after this step.

If I run "make tests" once in a debug build, without running it in the non-debug build first, or if I clear the test cache, then I get an error "Fatal error: Arginfo / zpp mismatch during call of filemtime()" which points to https://github.com/nette/di/blob/master/src/DI/DependencyChecker.php#L73.

I am unable to reproduce the segfault when running vendor/bin/phpunit.

If you get the "Error: Class "PHPStan\Analyser\Analyser" error, you will likely need to clear the test cache:

rm -rf /tmp/phpstan-tests/cache/nette.configurator/*

After clearing the test cache, you will need to repeat steps 3 and 4 above, as you will hit the "Fatal error: Arginfo / zpp mismatch during call of filemtime()" again.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC