Skip to content

Regression: AOT stream_get_meta_data(php://memory) empty keys — VM/JIT match Zend (ext/standard/streams.c) #27659

Closed

Description

@PurHur

Category

Regression · php-src-strict · AOT · pillar 4

Problem

stream_get_meta_data() on php://memory matches Zend on VM/JIT (wrapper_type=PHP, stream_type=MEMORY, mode set). Thin AOT returns an array whose expected keys are missing (?/?/NULL in probe) — silent wrong metadata. Prior closed issues (#16577/#19129/#25993) covered VM semantics only. Probed 2026-08-04 @ 4639761bd.

Repro Zend / VM / JIT AOT
wrapper_type / stream_type / isset(mode) on php://memory PHP / MEMORY / true missing keys (? / ? / NULL)

php-src reference

PHP implementation target

  • Fix AOT meta materialization for memory/temp streams (ext/standard stream meta helpers / JitStreamMeta* / VmFs) so keys match Zend
  • PHP-in-PHP; no new C in runtime/

Repro

./script/docker-exec.sh -- bash -lc '
cat > /tmp/sgmd.php <<'"'"'PHP'"'"'
<?php
$f = fopen("php://memory", "r+");
fwrite($f, "x");
rewind($f);
$m = stream_get_meta_data($f);
echo ($m["wrapper_type"] ?? "?"), "\n";
echo ($m["stream_type"] ?? "?"), "\n";
var_export(isset($m["mode"])); echo "\n";
PHP
php bin/vm.php /tmp/sgmd.php
php bin/jit.php /tmp/sgmd.php
php bin/compile.php -o /tmp/sgmd.bin /tmp/sgmd.php && /tmp/sgmd.bin
'

Done when

  • AOT prints PHP / MEMORY / true (same as Zend/VM/JIT)
  • php://temp stream_type matches Zend (TEMP vs MEMORY per php-src rules)
  • Targeted repro/compliance guard; php-src-strict

Gate context (same machine, 2026-08-04)

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 5, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (#27423 merged → #27659 #27573 #27437)

    Starting #27659 (AOT stream_get_meta_data php://memory keys).

  3. PurHur commented on Aug 5, 2026

    @PurHur
    OwnerAuthor

    Handoff — #27659 after #27423 merge

    #27423 merged: #27721

    #27659 repro (this workspace)

    With local StreamIo/StreamMeta helper units warmed + core marker (committed prelink core fingerprint 72a83ee ≠ live aa095c4c, so clean trees otherwise re-emit the whole corpus for ~minutes):

    Mode Result
    Zend / VM / JIT PHP / MEMORY / true
    Thin AOT ? / ? / NULL (empty/missing meta keys)

    Findings

    • Path: JitStreamGetMetaData → __compiler_stream_get_meta_data → StreamMetaJitHelper::getMetaDataArgv → VmFs::streamGetMetaData / VmStreamMeta::buildMetaArray.
    • Helper-runtime unit.o and NestedJIT of getMetaDataArgv both still yield missing keys (forcing USER_SCRIPT_INLINE_ONLY for getMetaDataArgv did not fix).
    • Hardcoding a 3-key HT inside getMetaDataArgv segfaulted under thin AOT — NestedJIT HashTable::add(string,…) for this return path looks unsafe; need LLVM-side string-key HT materialization (or a NestedJIT-safe builder) like other AOT meta/array returns.
    • Env note: touch build/helper-runtime-cache/core-<livefp>.ok after emitting StreamIo+StreamMeta units, or AOT spends minutes in emit-helper-runtime-object.php before compiling.

    Suggested next

    1. Build meta HT in LLVM from scalar NestedJIT returns (wrapper_type/stream_type/mode/… as separate *Argv ints/strings), or find a NestedJIT-safe HashTable string-key write used by a green AOT builtin and reuse it.
    2. Guard: AOT fixture mirroring the issue repro; php://temp TEMP vs MEMORY per done-when.
    3. Then Regression: AOT stream_context_set_params() compile segfaults — VM/JIT match Zend (re-#8063, ext/standard/streams.c) #27573 / Regression: AOT stream_get_contents(php://memory) segfaults after build — VM/JIT match Zend (ext/standard/file.c) #27437 in the same streams batch.

    Branch fix/27659-stream-get-meta-data-aot local only (no push — no fix yet).

  4. PurHur commented on Aug 5, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — continuing batch (#27659 → #27573 → #27437)

    Resuming from prior handoff on this workspace: NestedJIT HashTable string-key path for getMetaDataArgv; aiming LLVM-side HT materialization or NestedJIT-safe builder.

  5. PurHur commented on Aug 5, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — continuing batch (#27659 → #27573 → #27437)

    Resuming on fix/27659-stream-get-meta-data-aot: thin AOT LLVM meta from StreamGlobals paths (JitStreamMetaThinAot). Local probe: PHP/MEMORY/isset(mode)=YES + TEMP; shipping PR after gates.

  6. PurHur commented on Aug 5, 2026

    @PurHur
    OwnerAuthor

    Merged via #27833

    Verification

    Next in batch: #27573 → #27437

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