Fix bootstrap AOT segfault: CallArgv LLVM global cross-context leak (#14459)#14473
Merged
Conversation
…ntext leak (#14459). Guard CallArgv globals per LLVM module (LateStaticBindingGlobals pattern), bind the in-flight JIT Context before defineBuiltins for reentrant nested JIT, and route bootstrap-aot fixtures through thin standalone init so nested php-in-PHP helpers do not segfault during Context construction. Co-authored-by: Cursor <cursoragent@cursor.com>
PHP_COMPILER_BOOTSTRAP_AOT_LINK deferred inventory ob_* stubs were no-ops, so echo_hello AOT binaries linked but produced empty stdout. Mirror the user-script AOT path: direct STDOUT LLVM echo without nested ObOutputJitHelper. Co-authored-by: Cursor <cursoragent@cursor.com>
…pattern. Co-authored-by: Cursor <cursoragent@cursor.com>
…teRegistry JIT. compileCommon always links AttributeRegistryJitHelper, which calls __compiler_json_decode; thin bootstrap init must declare those ABI symbols before nested helper JIT (master #14470 + rebase). Co-authored-by: Cursor <cursoragent@cursor.com>
38e18c2 to
e1e4ce3
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.
Summary
lib/JIT/Builtin/CallArgv.php): guard__phpc_call_argv_htper LLVM module using the same pattern asLateStaticBindingGlobals— staticValuemust not leak acrossJIT\Contextinstances (php-src ref: nested JIT duringdefineBuiltins()/WeakRefRegistryRuntime::ensureJitHelperCompiled).lib/Runtime.php,lib/JIT/Context.php):claimJitContextSlot()binds the in-flight context beforedefineBuiltins()so nestedloadJitContext()during php-in-PHP helper JIT does not spawn a second module.lib/JIT/Context.php,bin/compile.php):test/bootstrap-aot/*auto-setsPHP_COMPILER_BOOTSTRAP_AOT_LINK=1and usesensureBootstrapAotStandaloneBodies()to avoid nested-JIT segfault inensureFullStandaloneBodies()(StringJsonEncode / StringGetenvAll path). Defer heavy emitters viaStreamIoRuntime+StringGetenvAllstubs when link flag is set.Verification
Issue repro (was exit 139 segfault):
Unit tests:
Remaining / handoff
make bootstrap-aot-linkno longer mass-segfaults on compile, but many fixtures still report output mismatch (AOT binary runs with empty stdout forecho_helloon this host) or compile failure — follow-up needed for standalone echo/output path under thin bootstrap init.ensureFullStandaloneBodies()withoutPHP_COMPILER_BOOTSTRAP_AOT_LINKstill segfaults in nested Json/Getenv JIT; thin path is the bootstrap gate fix for Bootstrap: CallArgv LLVM global leaks across JIT Context — bootstrap-aot-link segfault (#197) #14459.Closes #14459
Made with Cursor