[php-src] PR #19535: Fix incorrect opline after deoptimization
| From: | arnaud-lb | Date: | Wed, 20 Aug 2025 14:33:15 +0000 |
| Subject: | [php-src] PR #19535: Fix incorrect opline after deoptimization | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-32851@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/19535
Author: arnaud-lb
Fixes GH-19486 introduced by https://github.com/php/php-src/commit/76d7c616bb8775520f18456b41121bf934cac391.
Blacklisted side traces (aka JIT'ed exits) may return the previous opline after calling the
original op handler. As a result, the op handler is called again by the VM.
Fix this by always returning the opline returned by the original op handler.
Always use
zend_jit_vm_enter(jit, ref) to signal the VM that it must reload
EG(current_execute_data) as it may have changed during the execution of the trace.
This is consistent with non-JIT'ed exits: https://github.com/php/php-src/blob/0bf295944df7171acf47502d31dd7df8b9155d81/ext/opcache/jit/zend_jit_ir.c#L2488-L2489
And with the previous version of this code (ir_RETURN(ref) and
ir_RETURN(ir_CONST_I32(2)) have the same effect in this case) : https://github.com/php/php-src/blob/bc05bfe7c58a0df531e92cb43f3ea2e6332c3c68/ext/opcache/jit/zend_jit_ir.c#L17108-L17119
Analysis of the reproducer code in GH-19486:
The function floodFill() performs a deep recursion, exhausting the VM stack, causing a side exit in
zend_jit_push_call_frame(). The JIT'ed code of this side exit mistakenly returns the previous
opline to the VM, causing the same opline (INIT_FCALL) to be executed twice:
* The first time, the stack is extended and the new call frame is marked with ZEND_CALL_ALLOCATED
* The second time, we re-use the newly allocated stack, so the frame is not marked
The first frame never make it to the call stack. Returning from the second frame to its parent
creates the inconsistency that causes the assertion failure.