Skip to content

Fix GH-25165: Tracing JIT spins once the JIT buffer is full - #454

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/gh-25165-blacklisted-exit-spin
Closed

iliaal wants to merge 1 commit into
PHP-8.4from
fix/gh-25165-blacklisted-exit-spin

Conversation

@iliaal

@iliaal iliaal commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Once the JIT buffer is full, zend_jit_blacklist_trace_exit() blacklists a side exit it couldn't link, and every later hit returned 0 from zend_jit_trace_exit(). When that exit's opline is the root trace's start, resuming there re-enters the same trace, so the process spins at 100% CPU. Returning 1 in that case runs the original handler, the same guard zend_jit_trace_exit_to_vm() applies when it can emit a stub.

The test also needs dstogov/ir#295: failed compiles on a full buffer leak the DynASM state, and debug builds report it. Until that syncs, the test fails on debug lanes with a leak report even though the output is correct.

Reproduced on PHP-8.4 and master debug builds, hybrid and CALL VM.

Fixes phpGH-25165

When a side trace cannot be compiled because the JIT buffer is full,
zend_jit_blacklist_trace_exit() marks the exit blacklisted without linking
it. Every later hit of that exit returned 0 from zend_jit_trace_exit() and
resumed at EX(opline); when that is the root trace's start opline, its
handler is the trace itself, so execution re-entered the trace and took the
same exit forever. Return 1 in that case so the original handler runs, as
zend_jit_trace_exit_to_vm() already does when it can emit an exit stub.

Also backport IR commit 43d1d1023a6ea811b11b39ed738f5e18696a1254, which
frees the DynASM state when the code buffer is full.

Fixes phpGH-25165
@iliaal
iliaal force-pushed the fix/gh-25165-blacklisted-exit-spin branch from 7d262b1 to 634759c Compare November 3, 2026 21:34
@iliaal

iliaal commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

Submitted upstream: php#25182

@iliaal iliaal closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant