-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix GH-15657: Segmentation fault in ext/opcache/jit/ir/dynasm/dasm_x86.h #15819
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
Conversation
…_x86.h The crash happens because the zend_persist.c code tries to JIT the hook's op_array while the JIT buffer memory is still protected. This happens in `zend_persist_property_info` called via `zend_persist_class_entry` through the inheritance cache. We shouldn't JIT the property hook code when persisting property info for the inheritance cache. This is a simple workaround by temporarily disabling the JIT so that the property hook code is not JITted when persisting the property info. An alternative solution would be to move the JITting of the property hooks to a different place in zend_persist.c by doing an additional pass over the classes.
Actually, maybe this is not complete, because if I add the following code to the test at the bottom, it crashes (both with and without this patch): for ($i=0;$i<2;$i++)
echo (new A)->prop; I don't have time anymore today to analyse that crash though. It still happens even if I remove the inheritance for interface I, so maybe it's a slightly different bug. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably right.
cc: @iluuu1994
I analysed this and this is a different bug related to a cache slot optimization. Lines 2094 to 2126 in 7c2204c
This seems incompatible with how the minimal JIT works, getting the property will be skipped. |
I think you should commit the existent fix and open a new bug report. |
Merged and opened #15834 |
The crash happens because the zend_persist.c code tries to JIT the hook's op_array while the JIT buffer memory is still protected. This happens in
zend_persist_property_info
called viazend_persist_class_entry
through the inheritance cache. You can check that this is true by surrounding the JIT call withzend_jit_unprotect()
andzend_jit_protect()
.We shouldn't JIT the property hook code when persisting property info for the inheritance cache.
This is a simple workaround by temporarily disabling the JIT so that the property hook code is not JITted when persisting the property info.
An alternative solution would be to move the JITting of the property hooks to a different place in zend_persist.c by doing an additional pass over the classes.