Repository navigation
Conversation
When the JIT runs out of root traces, zend_jit_stop_counter_handlers() restores the original VM handlers of every cached script. It set jit_counters_stopped before doing so. If the process was killed in the loop, by SIGKILL or the OOM killer, later calls returned early and the remaining counting handlers stayed until the next restart: each hot loop or function still entered the tracer once before being blacklisted, and the cold ones kept paying for the counters. Set the flag after the loop, which can safely run again. Reported by Arnaud Le Blanc in php#25785.
arnaud-lb
reviewed
Nov 27, 2026
|
|
||
| /* Clean up used op_arrays */ | ||
| while (num_op_arrays > 0) { | ||
| op_array = op_arrays[--num_op_arrays]; |
Member
There was a problem hiding this comment.
Looks like op_arrays is unused after this change, so we could remove it in master.
The JIT builds the SSA, call graph and return info of the functions it compiles in their func_info in shared memory, from process-local arena memory, and clears them once done. The function JIT does so with the triggers that compile at run time (first execution, profiling or hot counters), the tracing JIT for every function a trace goes through. If the process was killed in between, by SIGKILL or the OOM killer, these func_infos kept pointers into the arena of the dead process until the server was restarted. Compiling a caller of such a function crashed, a trace entering it took its SSA as already built, and type inference read its stale return info. Record each func_info in a list in shared memory before writing to it, and reset the listed ones at the start and at the end of every compilation, in all JIT modes. With ZEND_CALL_TREE, the function JIT writes only to the func_info of the function it compiles, so its cleanup no longer walks the callees. That walk also cleared ZEND_FUNC_JITED on every callee, so a worker that waited for the lock compiled again a callee compiled meanwhile. Reported by Arnaud Le Blanc in php#25785.
dunglas
force-pushed
the
fix/opcache-kill-safety-2
branch
from
November 27, 2026 22:13
281e1a2 to
677d089
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In #25785 (review), @arnaud-lb pointed out some more places where a process killed in the middle of an update leaves the shm of OPcache half updated.
This PR fixes them, and one more in the tracing JIT.
Two other cases are handled by #25258 #25509.
Problems have been reproduced using GDB (breaking and sending the signal) with FPM, and fixes work as expected.
This is part of the reliability work to remove Zend Signals: #25627
This needs a careful review because I'm not familiar with this part of the code base and this is tricky to get right.