You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Segmentation fault in Zend/zend_vm_execute.h #15658
It seems setting the optimization level to 1 breaks many tests. E.g. php-dev run-tests.php -d opcache.enable_cli=1 -d opcache.jit=1201. I can also reproduce this on 8.2. /cc @dstogov
Then the ZEND_MATCH opcode is never called. Instead, after the DO_ICALL and exception check, the assembly does a call to the ZEND_MATCH_ERROR handler and then tailcalls to the opline handler.
So no wonder we get weird results if the wrong op is executed.
@nielsdos From the documentation, this jit mode is intended to only generate code that calls the vm handlers. So, I believe that not generating match code is expected.
JIT doesn't properly implement support for MATCH instruction when opcache.jit=1 (function jit without optimization).
This is a historical limitation (MATCH implementation didn't provide JIT support).
It would be good to fix this.
It's possible to call MATCH handler and then generate JIT code for N-way switch based on the value of opline register.
It's possible to call MATCH handler as a tail handler and pass the following control to VM interpreter.
Because function jit without optimization is probably not used a lot, I think fix number 2 is the most sensible when regarding the trade-off complexity vs worth.
Activity
iluuu1994 commentedon Aug 30, 2024
It seems setting the optimization level to
1breaks many tests. E.g.php-dev run-tests.php -d opcache.enable_cli=1 -d opcache.jit=1201. I can also reproduce this on 8.2. /cc @dstogovndossche commentedon Aug 31, 2024
If I reduce it to this:
Then the ZEND_MATCH opcode is never called. Instead, after the DO_ICALL and exception check, the assembly does a call to the ZEND_MATCH_ERROR handler and then tailcalls to the opline handler.
So no wonder we get weird results if the wrong op is executed.
I do see that there is no special handling, but perhaps this is intended to be generated somewhere else?
php-src/ext/opcache/jit/zend_jit.c
Lines 2542 to 2543 in 558ccf7
iluuu1994 commentedon Aug 31, 2024
@nielsdos From the documentation, this jit mode is intended to only generate code that calls the vm handlers. So, I believe that not generating match code is expected.
ndossche commentedon Aug 31, 2024
@iluuu1994 Yes, but I'm not seeing a call to the MATCH VM handler, only one to the MATCH_ERROR.
iluuu1994 commentedon Aug 31, 2024
Ah, ok. Sorry.
dstogov commentedon Sep 2, 2024
JIT doesn't properly implement support for MATCH instruction when opcache.jit=1 (function jit without optimization).
This is a historical limitation (MATCH implementation didn't provide JIT support).
It would be good to fix this.
ndossche commentedon Sep 6, 2024
Because function jit without optimization is probably not used a lot, I think fix number 2 is the most sensible when regarding the trade-off complexity vs worth.
Fix phpGH-15658: Segmentation fault in Zend/zend_vm_execute.h
Fix GH-15658: Segmentation fault in Zend/zend_vm_execute.h
Merge branch 'PHP-8.2' into PHP-8.3
Merge branch 'PHP-8.3'