Skip to content

Regression: AOT ParentIterator / MultipleIterator / RecursiveTreeIterator foreach silent empty — VM/JIT match Zend (ext/spl/spl_iterators.c) #27584

Closed

Description

@PurHur

Category

bug · php-src-strict · AOT · stdlib · pillar 4

Problem

Three SPL iterator wrappers match Zend on VM/JIT but AOT foreach is silent empty (rc=0) on master 22b85387e.

Repro Zend / VM / JIT AOT
ParentIterator(RecursiveArrayIterator(["a"=>1,"b"=>["c"=>2,"d"=>3]])) b empty
MultipleIterator attach L=[a,b] N=[1,2] a:1 b:2 empty
RecursiveTreeIterator(RecursiveArrayIterator(["a"=>["b"=>1,"c"=>2]])) \-Array| |-1| \-2| empty

Filed as one issue because the failure mode is the same AOT foreach/visitor path; split if a worker finds distinct root causes.

php-src reference

PHP implementation target

  • AOT foreach over these OuterIterator/RecursiveIterator classes in ext/spl/ + lowering
  • Prefer PHP-in-PHP; no new C runtime tables

Repro

./script/docker-exec.sh -- bash -lc 'cat > /tmp/spl_wrap.php <<'"'"'PHP'"'"'
<?php
echo "Parent:";
$p = new ParentIterator(new RecursiveArrayIterator(["a"=>1,"b"=>["c"=>2,"d"=>3]]));
foreach ($p as $k => $v) { echo "$k "; }
echo "\nMulti:";
$m = new MultipleIterator();
$m->attachIterator(new ArrayIterator(["a","b"]), "L");
$m->attachIterator(new ArrayIterator([1,2]), "N");
foreach ($m as $v) { echo implode(":", $v), " "; }
echo "\nTree:";
$t = new RecursiveTreeIterator(new RecursiveArrayIterator(["a"=>["b"=>1,"c"=>2]]));
foreach ($t as $v) { echo $v, "|"; }
echo "\n";
PHP
php /tmp/spl_wrap.php
php bin/vm.php /tmp/spl_wrap.php
php bin/compile.php /tmp/spl_wrap.php -o /tmp/spl_wrap
/tmp/spl_wrap; echo rc=$?'

Done when

  • AOT matches Zend/VM/JIT for all three snippets (rc=0) across ≥3 runs
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    bugSomething isn't working
    phase-4:stdlibPhase 4 – stdlib for web apps
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Aug 4, 2026
  2. PurHur commented on Aug 4, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (#27583 #27568 #27581 #27582 #27584 #27565) — starting with #27583 NoRewindIterator AOT foreach

  3. PurHur commented on Aug 4, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (#27565 #27584 #27633 #27567 #27259) — queued after #27565

  4. PurHur commented on Aug 4, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — continuing batch after #27565 merged — starting #27584

  5. PurHur commented on Aug 4, 2026

    @PurHur
    OwnerAuthor

    Merged: #27672

    Verification: Zend / VM / AOT ×3 all match

    Parent:b 
    Multi:a:1 b:2 
    Tree:\-Array|  |-1|  \-2|
    

    phpunit --filter spl_wrap_iterators_foreach OK; inventory 7004/7004; spine coverage OK.

    Fix: pure-LLVM HT snapshots + usesArrayIteratorHt for the three wrappers (NestedJIT bridges segfault under thin AOT).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITbugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions