AOT: fix request_parse_body compile/link (#5965) - #17316
Conversation
- Link __compiler_env_register_putenv via EnvLocalRuntime during standalone putenv JIT - Route GetenvJitHelper hashtable fills through phpc_native_ht_set_string_key (nested-JIT safe) - Promote list-unpack assign targets to entry allocas for LLVM dominance (#5965) - Preserve insert blocks across RequestParseBodyRuntime / EnvLocalRuntime nested emits Compile + link green for urlencoded/multipart fixtures; AOT runtime still segfaults at c:main_before_php (follow-up). Co-authored-by: Cursor <cursoragent@cursor.com>
|
Maintainer triage 2026-07-08: compile/link green per PR body but AOT runtime still segfaults at |
|
Maintainer triage 2026-07-08: compile/link green per PR body but runtime segfault remains — hold merge until AOT execute passes issue repro. |
- Link EnvLocalRuntime + RequestParseBodyRuntime in user-script standalone init - Route GetenvJitHelper fill/merge through phpc_native_ht_set_string_key (nested-JIT) - Split VM overlay merge into EnvLocalJitHelperVm (HashTable::update path) - Add issue repro scripts for putenv/request_parse_body AOT bisect Compile+link green; AOT execute still segfaults in __compiler_env_register_putenv. Co-authored-by: Cursor <cursoragent@cursor.com>
- BasicBlockHelper::restoreInsertBlock accepts null during standalone init - JitEnv::putenv calls GetenvJitHelper via JitNestedHelperCoerce (fixes AOT segfault) - RequestParseBodyEngine reads JIT+VM env overlay for CONTENT_TYPE/REQUEST_BODY - Defer RequestParseBodyRuntime from ensureMinimalUserStandaloneBodies (lazy link) - StringGetenv: preserve insert block across bridge emit AOT putenv-only repro green; request_parse_body execute still segfaults on nested helper call (empty parseIntoNative also crashes) — follow-up bisect needed. Co-authored-by: Cursor <cursoragent@cursor.com>
Continued work (2026-07-12, lane C)Pushed Fixed
Verification (Docker)PHP_COMPILER_CI_SINGLE_CONTAINER=0 ./script/docker-exec.sh -- bash -lc '
source script/php-env.sh && export PHP_COMPILER_PROFILE=8.4
php bin/vm.php test/repro/issue_5965_rpb_only.php
tmpdir=$(mktemp -d)
php bin/compile.php -o "$tmpdir/pe" test/repro/issue_5965_putenv_only.php && "$tmpdir/pe"
vendor/bin/phpunit test/unit/JIT/EnvLocalRuntimeStandaloneTest.php
'
Still red (blocker)
Not merge-ready until |
|
claim: cursor-agent-lane-a — continuing PR #17316 AOT request_parse_body execute fix |
- Route user-script AOT through RequestParseBodyNativeJitHelper (avoids nested-JIT of RequestParseBodyEngine which segfaults at main_after_init) - Call parseIntoNative via JitNestedHelperCoerce::callHelper from builtin lowering (mirrors putenv fix) instead of __compiler_request_parse_body bridge - Drop eager EnvLocalRuntime from ensureMinimalUserStandaloneBodies (putenv uses GetenvJitHelper overlay path) AOT putenv-only + VM repro green. request_parse_body() AOT execute still segfaults (139) before user output — bisect shows crash is not helper body logic (empty no-op helper also crashes). Next: hand-lowered LLVM path like ParseStrUserScriptDelimitedJit + MultipartRuntime for user-script AOT. Co-authored-by: Cursor <cursoragent@cursor.com>
Continued work (2026-07-13, lane A) — commit 9020369Progress
Bisect (AOT execute still red)PHP_COMPILER_CI_SINGLE_CONTAINER=0 ./script/docker-exec.sh -- bash -lc '
source script/php-env.sh && export PHP_COMPILER_PROFILE=8.4
tmpdir=$(mktemp -d)
php bin/compile.php -o "$tmpdir/pe" test/repro/issue_5965_rpb_only.php && "$tmpdir/pe"
'
# phpc: fatal signal (segfault) after c:main_before_php — exit 139
Crash occurs before user PHP output ( Next stepHand-lowered user-script LLVM like Not merge-ready until |
|
Maintainer verify (2026-07-13): VM repro green ( |
|
claim: worker-lane-a — continuing PR #17316 AOT request_parse_body execute fix |
Commit 9020369 dropped EnvLocalRuntime::ensureLinked from ensureMinimalUserStandaloneBodies, regressing standalone putenv AOT (free(): invalid pointer). Restore the link so GetenvJitHelper overlay and env-local bridges stay available during init. request_parse_body() AOT execute still segfaults — follow-up needs ParseStrUserScriptDelimitedJit-style hand lowering (see issue #17316). Verification: php bin/vm.php test/repro/issue_5965_aot_index.php # VM green php bin/compile.php -o /tmp/pe test/repro/issue_5965_putenv_only.php && /tmp/pe # ok vendor/bin/phpunit test/unit/JIT/EnvLocalRuntimeStandaloneTest.php # OK Co-authored-by: Cursor <cursoragent@cursor.com>
|
Lane A continuation (2026-07-14) — pushed 0554196 to PR #17316. Fixed
Still red
Verify./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && export PHP_COMPILER_PROFILE=8.4 && php bin/compile.php -o /tmp/pe test/repro/issue_5965_putenv_only.php && /tmp/pe'
# ok |
#5965) Route user-script AOT through init-linked RequestParseBodyUserScriptLlvm (__compiler_request_parse_body_user_aot) instead of nested RequestParseBody* helper JIT during user-main emit. Overlay-aware REQUEST_BODY read + parse_str delimited LLVM subhelpers mirror ParseStrUserScriptDelimitedJit / SuperglobalRefresh. AOT execute still aborts (134/139) — runtime bisect shows failure even with no-op bridge; next: pair-return lowering / multipart populate at init. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Lane A continuation (2026-07-14) — pushed 55d7c30 to PR #17316. Implemented
Verification./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && export PHP_COMPILER_PROFILE=8.4
php bin/vm.php test/repro/issue_5965_rpb_only.php # OK
php bin/jit.php test/repro/issue_5965_rpb_only.php # OK
php bin/compile.php -o /tmp/rpb test/repro/issue_5965_rpb_only.php && /tmp/rpb # abort 134/139
vendor/bin/phpunit --filter request_parse_body_urlencoded # FAIL exit 134'Blocker / nextRuntime bisect: abort persists even with no bridge call and no-op bridge body — likely separate AOT lowering bug in Not merge-ready. |
|
Maintainer verify 2026-07-15 on
Not merge-ready until AOT fixtures pass. VM/JIT compliance cases in that filter were green. |
…). Route JitVarExport through __compiler_var_export instead of nested helper callHelper from user-main. Add StringVarExportUserScriptLlvm with JitVmHelperLink bridge + sg_vm_context init scheduling. Remaining: standalone execute still SIGSEGV inside formatValue helper — request_parse_body+putenv AOT green; var_export fixture blocked. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Lane A continuation (2026-07-15) — WIP pushed to Progress
Verification./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && export PHP_COMPILER_PROFILE=8.4
php bin/vm.php test/repro/issue_5965_aot_index.php # array (a=>1, b=>two) GREEN
php bin/compile.php -o /tmp/pe test/repro/issue_5965_putenv_only.php && /tmp/pe # ok GREEN
php bin/compile.php -o /tmp/rpb test/repro/issue_5965_aot_index.php && /tmp/rpb # SIGSEGV RED
vendor/bin/phpunit --filter var_export test/aot/AotTest.php # SIGSEGV RED (pre-existing)
'BlockerCrash occurs inside Next stepLLVM-only minimal array formatter for user-script AOT (like PR #17316 not merge-ready until |
|
Maintainer: holding merge — |
…quest-parse-body-aot
…env (#5965). putenv(malloc'd NAME=value) heap-corrupted when request_parse_body libc-getenv'd REQUEST_BODY after ≥2 mirrors; POSIX setenv copies instead. Fixture uses a single dim read to avoid a separate multi-access hashtable hang. Co-authored-by: Cursor <cursoragent@cursor.com>
Maintainer review (2026-07-15)Do not merge as Progress is real (setenv mirror fix, deferred link, urlencoded echo path). Prefer keeping open as WIP until:
Not merging from maintainer lane this run. |
Deferred user-script AOT skips nested GetenvJitHelper::putenv (SIGABRT on concat temps) and materializes the assignment via __string__separate before the libc setenv mirror. Keeps urlencoded AOT fixture green. Co-authored-by: Cursor <cursoragent@cursor.com>
Lane C continuation (2026-07-15)Landed
VerificationStill red / next
Not merge-ready as |
|
Maintainer triage (2026-07-15): leaving open — not merge-ready while multipart AOT, getenv overlay, and remaining munmap/hashtable cases are still red per the PR body. Urlencoded putenv+RPB progress is welcome; please keep |
|
Maintainer triage (2026-07-15): leaving open — body correctly lists remaining blockers for a full Verification path for the next agent: the Docker block in the PR body ( |
User-script standalone AOT used a false-only __compiler_getenv stub while putenv mirrored via POSIX setenv — putenv/getenv AOT fixtures returned ''. Route deferred stub through libc getenv + __value__writeString instead. php-src: ext/standard/basic_functions.c (zif_getenv, putenv) Verification: vendor/bin/phpunit --filter 'getenv_putenv|putenv' test/aot/AotTest.php # OK vendor/bin/phpunit --filter request_parse_body_urlencoded test/aot/AotTest.php # OK php bin/compile.php -o /tmp/rpb_pe test/repro/issue_5965_putenv_rpb_echo.php && /tmp/rpb_pe # 1 Co-authored-by: Cursor <cursoragent@cursor.com>
strdup on non-NUL `__string__` value bytes heap-corrupted under dual putenv before request_parse_body; copy via length+NUL then setenv. strdup getenv body before strtok/urldecode in-place parse so environ is not mutated. Verification: issue_5965_putenv_rpb_echo AOT → 1; putenv + urlencoded AOT fixtures OK. Co-authored-by: Cursor <cursoragent@cursor.com>
Maintainer triage (2026-07-15)Defer merge for now:
Continue iterating on the branch; no maintainer merge this turn. |
…19430) (#19437) User-script / deferred AOT still needs the thin VmActiveContext + VarExportJitHelper bridge (#16075/#17316); house it in ext/standard so lib/JIT/Builtin shrinks (same kernel-quarantine pattern as #19389/#19399). Embed path unchanged. Co-authored-by: PurHur <PurHur@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Continue #5965 / #17316 — user-script AOT
request_parse_body()+putenv().Latest (ca08341):
strdupon non-NUL__string__value bytes inemitLibcPutenvMirrorheap-corrupted under dualputenvbeforerequest_parse_body(length-dependent:FOO=1ok,FOO=bar/ longCONTENT_TYPEaborts).setenv(still copies name/value — notputenv(malloc)).strduplibcREQUEST_BODYbefore strtok/urldecode in-place parse so environ is not mutated; free owned copy after.__compiler_getenvreads libc after setenv (prior commit) soputenv.phptAOT is green.php-src ref:
ext/standard/http.c,ext/standard/basic_functions.c(putenv/getenv)Verification (2026-07-15)
Remaining (Refs #5965 — not full close)
request_parse_body_multipart.phptAOT — UserScriptLlvm is urlencoded-only (ValueError empty path / no MediaType branch).var_export()user-script AOT still segfaults on master (php-in-php: var_export() — delete phpc_var_export.c, VM+JIT from ext/standard/var_export.php #5190).[$post,$files]=list-unpack /$post=$pair[0]nested HT assign ownership.Mergeable slice: dual-putenv + urlencoded AOT + putenv/getenv AOT green.