[php-src] PR #22515: Defer user error handlers raised from user-code opcodes
| From: | iliaal | Date: | Mon, 29 Jun 2026 20:57:15 +0000 |
| Subject: | [php-src] PR #22515: Defer user error handlers raised from user-code opcodes | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36738@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22515
Author: iliaal
Defers a user error handler raised from a user-code opcode to the next VM safepoint, after the
opcode completes, so the handler cannot reenter and free or mutate state the opcode still holds a
raw pointer into. The interpreter and both JITs reach that safepoint through the existing
vm_interrupt mechanism. A diagnostic silenced by @ keeps its error_reporting across the deferral.
Function JIT flushes at the interpreter's safepoints: post-call with the callee frame still on
top, each jump-target block, and function entry, spilling the live SSA values before it resumes.
Exception handling flushes any buffered diagnostic with the pending exception saved and restored
around the handler, so nothing is dropped when a later opcode throws. Diagnostics raised from
internal functions still run synchronously, since the function may gate on EG(exception) or throw
right after emitting; php_sort() and the array pointer functions pin their by-ref argument across
the deprecation they raise.
Under the CALL VM (Windows and macOS), a deferred error could otherwise flush while a call frame is
being assembled: the throwing handler would unwind into the half-built frame and
cleanup_unfinished_calls would destroy an unsent argument slot, which is NULL there (the hybrid VM
keeps a live value, so glibc/x86_64 never faults). The flush is deferred past a call being assembled
in both the interpreter interrupt helper and the JIT interrupt stub, so this cannot happen.
This is a narrow, error-handlers-only take on GH-20018. arnaud-lb/php-src#31 is the broader
reference: it also delays destructors and adds a set_error_handler($delay) opt-out with
PromotedErrorException.