Repository navigation
Closed
Labels
area:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsPhase 4 – stdlib for web apps
Description
Category
stdlib · php-src-strict | runtime
Problem
parse_str() with nested bracket notation (b[c]=2&b[d][]=3&b[d][]=4) aborts the VM with:
Refcount is > 1, but was asserted to be 1
instead of building the nested array Zend returns. #6013 closed the JIT/AOT/php-in-PHP micro-runtime path; VM VmParseStr::mergeInto() is still broken for nested keys + list append.
This blocks query-string parsing in web/runtime code (#5965, #5330).
php-src reference
- php/php-src
ext/standard/parse_str.c—PHP_FUNCTION(parse_str),php_parse_str() - Nested key walk: bracket segments +
[]list append semantics
Repro (verified 2026-06-06)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro-maintainer/parity_parse_str_brackets_regression.php
php bin/vm.php test/compliance/cases/stdlib/parse_str_brackets.phpt
php -r "\$o=[]; parse_str(\"a=1&b[c]=2&b[d][]=3&b[d][]=4\",\$o); var_export(\$o);"
'| Runtime | Result |
|---|---|
| Zend | array('a'=>1,'b'=>array('c'=>2,'d'=>array(3,4))) |
| VM | Refcount abort ❌ |
| Expected PHPT | 1:2:3:4 output |
Scope (this repo) — PHP-in-PHP first
| Path | Role |
|---|---|
| VM fix | ext/standard/VmParseStr.php — mergeInto() refcount when nesting arrays + appending list keys |
| Handler | ext/standard/parse_str.php — keep host \parse_str() import or pure PHP parser aligned with VM |
| JIT/AOT | lib/JIT/Builtin/StringParseStr.php, StringParseStrJit.php — match VM after fix (#6308 phase 2) |
| C | Do not reintroduce runtime/phpc_parse_str.c (removed #6013) |
php-src-strict
- Match Zend nested structure and scalar/list typing exactly
- Enum case variable names →
TypeError(separate guard family; do not regress while fixing merge)
Done when
- Repro +
test/compliance/cases/stdlib/parse_str_brackets.phptgreen on VM - No refcount abort on nested bracket +
[]append keys -
./script/ci-fast.sh --filter parse_str_bracketsgreen - JIT/AOT compliance row green when php-in-php: parse_str() JIT — delete __phpc_parse_str_* LLVM micro-runtime (phase 2 of #6013) #6308 aligns lowering (optional same PR if trivial)
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/compliance/cases/stdlib/parse_str_brackets.phpt
vendor/bin/phpunit --filter parse_str_brackets
'Related
- php-in-php: parse_str() JIT/AOT — delete lib/AOT/runtime/phpc_parse_str.c, share VmParseStr PHP semantics #6013 (closed) JIT path · php-in-php: parse_str() JIT — delete __phpc_parse_str_* LLVM micro-runtime (phase 2 of #6013) #6308 delete JIT micro-runtime · Stdlib: request_parse_body() — PHP 8.4 HTTP body parser without superglobals (ext/standard/http.c) #5965 request_parse_body · Epic: Self-host critical path — compiler compiles itself (M3→M5) #1492
Metadata
Metadata
Assignees
Labels
area:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsPhase 4 – stdlib for web apps
Activity
PurHur commentedon Jun 7, 2026
claim: worker-lane-c — starting this run
Fix parse_str() nested bracket merge refcount abort (#6521) (#7558)
PurHur commentedon Jun 7, 2026
Merged via #7558.
Fix:
VmParseStr::ensureArrayChild()now callsseparateArrayForWrite()on the bucket zval before returning a child HashTable for in-placemergeInto()—HashTable::add()had bumped refcount viacopyFrom(), causing the nested bracket +[]append path to abort.Verification:
```bash
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro-maintainer/parse_str_brackets.php
vendor/bin/phpunit --filter parse_str_brackets
'
```
Repro output matches Zend nested structure; PHPUnit
parse_str_bracketsgreen (VM + JIT).