Repository navigation
Conversation
A JIT compile stores SSA and call graph data in the shared func_info of the op_arrays it touches, and clears it when the compile ends. If a signal killed the process before that, func_info kept pointing into the dead process's arena, and the next compile in another process reused it. Defer signals during the compile, as opcache already does around other SHM updates. A function compile that bailed out skipped the cleanup too. Clean up on bailout as well.
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.
JIT compiles store SSA and call graph data in the shared
func_infoof the op_arrays they touch, and clear it when the compile ends. If a signal kills the process mid-compile,func_infokeeps pointing into the dead process's arena. The next compile in another process reuses it and crashes, or hitsAssertion failed: info & (1 << type)inzend_jit_trace_type_to_info_ex().This is the cause of the intermittent
ext/pcntl/tests/001.phptfailure on ALPINE_X64_ASAN_DEBUG_ZTS: a forked child gets SIGTERM while compiling a trace, and the parent reuses its leftover SSA. In production, FPM'srequest_terminate_timeoutsends the same SIGTERM.Fix:
HANDLE_BLOCK_INTERRUPTIONS(). Opcache already does this around its other SHM updates (ad55348). The JIT never did.func_infowhen a function compile bails out too. Every blocked section unblocks before re-throwing the bailout (see 38f1288).Concerns:
func_infoon the next compile. I have that version, but it's more invasive than a fix for 8.4 should be.--disable-zend-signalsbuilds, where the macros compile to nothing.The tests fork a child and set
opcache.jit_debug=2in it, so it blocks writing the SSA dump to a socket in the middle of a compile. The parent sends SIGTERM, then runs code that would reuse the leftover data. All five tests crash under ASan without the fix.Merging up: applies cleanly to PHP-8.5. On master there's a trivial conflict,
0/1vsfalse/truein thezend_jit_check_funcs()calls.The flaky test is the first attempt of ALPINE_X64_ASAN_DEBUG_ZTS on PR #25946, which failed: https://github.com/php/php-src/actions/runs/46443912300/job/141936152537
The re-run passed: https://github.com/php/php-src/actions/runs/46443912300/job/141988272688