Skip to content

Foundation: Zend gen-0 of compiler_minimal hangs after compiletofile_done (link gate never finishes) #31726

Description

@PurHur

Category

Foundation: · bootstrap-selfhost-link · Zend gen-0 fallback hang

Problem

When committed prelinked/bootstrap-gen0 is lowering-fingerprint stale, ./script/bootstrap-selfhost-gate.sh link falls back to Zend AOT of test/selfhost/compiler_minimal/main.php. Under PHP_COMPILER_DOCKER_MEM=16g the emit succeeds (build/selfhost runs and prints compiler_minimal bundle OK) and progress reaches runtime_standalone_compiletofile_done, but php bin/compile.php never exits — it stays at ~100% CPU / ~4.7 GiB RSS for 15+ minutes after the artifact is stable. The link gate therefore never reaches the smoke loop or prints bootstrap-selfhost-link: OK.

Probed 2026-08-17 on master @81c0eecf41 (post-#31725).

Step Result
Default 10g docker mem Fail-fast #31714 (expected)
Remount 16g + Zend gen-0 Artifact written + runs OK; compile.php hung after compiletofile_done
Manual ./build/selfhost compiler_minimal bundle OK (exit 0)

php-src reference

N/A (compiler pipeline / AOT teardown). Related history: #21925 (intermittent post-OK abort), #31714 (16g remount).

PHP implementation target

  • bin/compile.php / lib/AOT/ / lib/JIT/ path after runtime_standalone_compiletofile_done — must exit 0 once -o artifact is linked
  • Optionally script/bootstrap-resolve-compile-invoke.sh / link gate: treat stable executable + progress marker as success with a bounded wait (do not hang forever)
  • No new runtime/*.c

Repro

docker info >/dev/null
# ensure gen-0 fingerprint is stale (normal tip drift)
PHP_COMPILER_DOCKER_MEM=16g PHP_COMPILER_DOCKER_MEM_SWAP=16g \
  ./script/docker-exec.sh -- bash -lc './script/bootstrap-selfhost-gate.sh link'
# observe: build/selfhost becomes runnable while php bin/compile.php continues at 100% CPU

Done when

  • Zend gen-0 of compiler_minimal exits 0 shortly after writing a runnable -o binary
  • ./script/bootstrap-selfhost-gate.sh link at 16g prints bootstrap-selfhost-link: OK (or native gen-0 path when fingerprint fresh)
  • No fingerprint restamp; php-src-strict N/A (tooling/pipeline)

Activity

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

    @PurHur
    OwnerAuthor

    claim: lane-B compile/link implementer — starting this run (bootstrap fallback; first red was #31714@10g, then Zend hang after successful emit)

  3. PurHur commented on Aug 17, 2026

    @PurHur
    OwnerAuthor

    claim: lane-B implementer — continuing #31726 (post-compiletofile_done hang; investigating _exit before LLVM/PHP teardown)

  4. PurHur commented on Aug 17, 2026

    @PurHur
    OwnerAuthor

    Merged #31741.

    Fix: _exit(0) at end of Runtime::standalone() after successful selfhost compileToFile, before JIT Context destructor (LLVM teardown hang / #21925 abort).

    Verified: SelfhostAotFastExitTest OK; tiny test/selfhost/ AOT exits with progress runtime_standalone_fast_exit.

  5. PurHur commented on Aug 17, 2026

    @PurHur
    OwnerAuthor

    Merged #31742

    Verification

    • ./script/phpunit.sh --filter SelfhostAotFastExitTest — OK (6)
    • Tiny selfhost AOT: rc=0 in ~14s after runtime_standalone_compiletofile_done
    • PHP_COMPILER_DOCKER_MEM=16g PHP_COMPILER_DOCKER_MEM_SWAP=16g ./script/docker-exec.sh -- bash -lc './script/bootstrap-selfhost-gate.sh link' → bootstrap-selfhost-link: OK / compiler_minimal bundle OK (clean _exit; watchdog not needed)

    Fix: warm libc _exit before LLVM; exit immediately after successful selfhost emit; Zend invoke watchdog as backup.

  6. PurHur commented on Aug 17, 2026

    @PurHur
    OwnerAuthor

    Follow-up merged: #31742 (on top of #31741)

    Hardening beyond the initial _exit in Runtime::standalone:

    • lib/AOT/AotEmitFastExit warms libc _exit via libc.so.6 before LLVM FFI grows
    • bootstrap_compile_invoke_zend post-emit hang watchdog (BOOTSTRAP_SELFHOST_POST_EMIT_GRACE_SEC)

    Full link gate (this worker):
    PHP_COMPILER_DOCKER_MEM=16g PHP_COMPILER_DOCKER_MEM_SWAP=16g ./script/docker-exec.sh -- bash -lc './script/bootstrap-selfhost-gate.sh link'
    → bootstrap-selfhost-link: OK / compiler_minimal bundle OK / EXIT:0

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:toolingTooling / CI / docsbugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevEx

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions