Skip to content

Fix GH-24445: Tracing JIT loses register-allocated CVs i… - #24995

Open
devnexen wants to merge 1 commit into
php:masterfrom
devnexen:gh24798
Open

devnexen wants to merge 1 commit into
php:masterfrom
devnexen:gh24798

Conversation

@devnexen

Copy link
Copy Markdown
Member

Should also fix GH-24798

@devnexen devnexen changed the title Fix GH-24445 / GH-24798: Tracing JIT loses register-allocated CVs i… Fix GH-24445: Tracing JIT loses register-allocated CVs i… Oct 28, 2026
@devnexen
devnexen marked this pull request as ready for review October 28, 2026 08:20
@devnexen
devnexen requested a review from dstogov as a code owner October 28, 2026 08:20
@devnexen
devnexen requested a review from ndossche October 30, 2026 08:21
@ndossche

Copy link
Copy Markdown
Member

I can only review this in the evening, but can you please explain the analysis and reasoning in the PR so I don't have to fully reconstruct it?

@devnexen

Copy link
Copy Markdown
Member Author

I can only review this in the evening, but can you please explain the analysis and reasoning in the PR so I don't have to fully reconstruct it?

Sure. When a call in the trace throws, the JIT code leaves through jit_stub_exception_handler to the VM's HANDLE_EXCEPTION, and the catch runs in the interpreter, reading CVs from the frame. Unlike a side exit, that path has no snapshot, so register-only CVs are never written back: the catch sees UNDEF ($n in GH-24445) or a stale value ($s in GH-24798). Hence 1054 being fine.

The fix sets ZREG_STORE on CVs of op_arrays with try/catch in zend_jit_trace_allocate_registers(), so defs also reach the frame. ZREG_LOAD ranges are skipped as their slot is already in sync, and functions without try/catch are unaffected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP 8.5.12 tracing JIT produces incorrect sums when DivisionByZeroError is caught inside a loop

2 participants