[php-src] PR #22028: Fix GH-21368 follow-up: escape_if_undef on CALL VM

From: Date: Tue, 12 May 2026 20:22:35 +0000
Subject: [php-src] PR #22028: Fix GH-21368 follow-up: escape_if_undef on CALL VM
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-36110@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/22028 Author: iliaal Follow-up to #21368, kept separate from #21710 per arnaud-lb's review on the original commit. Two issues in zend_jit_escape_if_undef reachable on debug Clang/CALL builds of PHP-8.4. ir_CONST_ADDR for orig_handler registers the handler as IR_ADDR in jit->addr_hash. During a side-trace compile, zend_jit_trace_handler at zend_jit_ir.c:16849 calls ir_CONST_FC_FUNC(call_handler) for a subsequent opline whose handler happens to match the earlier registration, tripping the FUNC_ADDR assertion in jit_CONST_FUNC_PROTO. The ir_TAILCALL_1 to orig_handler returns IR_I32; on PHP-8.4's CALL VM execute_ex reloads execute_data only when the handler's return value is non-zero. A tail-call discards that signal, so a frame-changing handler leaves execute_data stale, and the next handler crashes dereferencing EX(call). gh21267.phpt with opcache.jit_hot_loop=1, jit_hot_func=1, jit_hot_return=1, jit_hot_side_exit=1, memory_limit=-1 reproduces a SEGV in ZEND_DO_FCALL. Switch to ir_CONST_FC_FUNC so addr_hash registers as FUNC_ADDR, and replace the tail-call with ir_CALL_1 + ir_RETURN(ir_CONST_I32(1)), mirroring the ZEND_FUNC_RECURSIVE_DIRECTLY branch in zend_jit_tail_handler. execute_ex then reloads execute_data from EG(current_execute_data) after the deopt. The ir_CAST_FC_FUNC on x86 becomes dead. gh21368_call_vm.phpt covers the CALL-VM crash with the aggressive trace ini. The FUNC_ADDR assertion case wasn't tractable to minimize into a self-contained .phpt. Reproduced reliably via Symfony Symfony\Component\HttpClient\Tests\AmpHttpClientTest running tests testIgnoreErrors, testDnsError, testInlineAuth, and testBadRequestBody in sequence: the assertion fires during the side-trace compile for HttpClientTrait::prepareRequest():100 (parent trace 1968, exit 13). Smaller subsets do not trigger. The COMMUNITY CI job catches regressions. Debug Clang/CALL PHP-8.4: with the fix, Symfony HttpClient runs to completion (1170/1171, 1 DNS env failure) and gh21368_call_vm.phpt passes. Without the fix, Symfony aborts after 14 tests on the FUNC_ADDR assertion, and the new test SEGVs in ZEND_DO_FCALL. /cc @arnaud-lb: you offered to handle this; I took a first cut so we have something concrete. Please reshape if the runtime trace state suggests a different fix.

« previous php.git-pulls (#36110) next »