Fix GH-15657: Segmentation fault in ext/opcache/jit/ir/dynasm/dasm_x86.h#15819
Fix GH-15657: Segmentation fault in ext/opcache/jit/ir/dynasm/dasm_x86.h#15819ndossche wants to merge 1 commit intophp:masterfrom
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. |
dstogov
left a comment
There was a problem hiding this comment.
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_infocalled viazend_persist_class_entrythrough 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.