-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation fault in PHP 8.1 #8461
Comments
I'm pretty sure this is the source of the problems in #7817. In our application (embedded hardware), there are several PHP files that are generated by other C programs which are overwritten often. |
Wow! Great job, Oleg! |
After some research, I found that the problem occurs here https://github.com/php/php-src/blob/PHP-8.1/ext/opcache/jit/zend_jit_x86.dasc#L10044 |
I confirm this. The run_time_cache__ptr of the sub class constructor changes when the parent class is recompiled. The crash happens because the old run_time_cache offset is still used by the generated code. Change of the run_time_cache__ptr happens during zend_do_link_class, when the inheritance cache is persisted. Reverting the changes made by JIT on the op array would fix the issue. I think that we are not supposed to reuse the JIT code here. |
A simple fix is to remove 2 branches with specific cases and leave one generic: It's also strange that the second branch uses To remove the JIT code in this case, I think we need to remove the JIT code of all callers when the callee code changes. |
Tested with #8535, everything works fine for me |
@oleg-st what do you mean by "Disabling inheritance cache ...", did you just dropped commit and built php without it? Or is there a reasonably small patch which makes inheritance cache effectively disabled? We have another issue with inheritance cache. It blocks us from upgrading php version. Considering amount of time issue hangs without any movement, disabling inheritance cache (even by patching php) seems to be not so bad alternative. |
@rs-orlov php-src/ext/opcache/ZendAccelerator.c Lines 3342 to 3343 in bec1552
|
Description
The problem is quite difficult to reproduce.
Need to change php files when running specific application in php-fpm.
Steps to reproduce:
bugphp.zip
ab
to executerun.php
frombugphp.zip
:Application touches
UniqueList.php
to make it modified for the OPcache.Segmentation faults:
Backtrace:
Bisect found the commit that contains the problem: 4b79dba
Disabling inheritance cache solves the problem.
The
UniqueList
class has a child classUniqueListLast
that uses some of the parent class's constants. And the modification of the parent class somehow leads to the problem.Possible related to #7817
PHP Version
PHP 8.1
Operating System
AlmaLinux release 8.5 (Arctic Sphynx)
The text was updated successfully, but these errors were encountered: