Skip to content

Reliability: memory-safety CI — ASan/UBSan runtime build, valgrind on the smoke set, a PHPC_RUNTIME_ASSERT=1 mode that checks refcount/ownership invariants, and a written memory-model spec the assertions are derived from (lib/AOT/Linker.php, lib/JIT/Builtin/Refcount.php, docs/runtime-semantics.md) #36397

Description

@PurHur

Category

Foundation: · the recurring defect class · child of #36379

Why

AGENTS.md calls intermittent heap corruption "a recurring defect class" (7/10, 6/10, 3/5 pass rates for the same binary). Wave 1 added and then reverted a destructor path that "broke all user-script AOT compile", found refcounts that never drop in {main}, a GC that segfaulted at 2,000 objects, and an over-aligned __value__ that was UB under optimisation. There is no sanitizer build, no valgrind job, no runtime assertion mode, and no document stating the ownership rules (who addrefs, who delrefs, when a container is separated). Without a spec, every fix is a guess and every gate is a coin flip.

Deliverable

  • docs/runtime-semantics.md §Memory model: invariants for __ref__ (who owns a count), boxed temporaries, {main} vs function scope, container separation, string immortality, helper-unit boundaries, GC roots; each invariant numbered.
  • PHPC_RUNTIME_ASSERT=1 build mode: __ref__addref/delref/separate and the dtors check the numbered invariants (rc > 0 on delref, no delref of immortal, no write to a shared container) and abort with the invariant number and a PHP-level trace (Add $_GET superglobal support for VM web scripts #16).
  • ASan/UBSan: --asan link (Add $_GET superglobal support for VM web scripts #16) + runtime allocations poisoned on free; weekly workflow runs aot-smoke, the differential corpus (--repeat 3) and the Stdlib: pi, angle conversion, log/exp, and float checks #10 soak under ASan; valgrind --error-exitcode=1 on the 9 smoke cases nightly.
  • Every memory-safety fix PR must add a differential case marked @differential-repeat: 10.

Done when

Activity

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

    IMPORTANTCritical patharea:compilerCompiler / CFG / JITenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-3:aotPhase 3 – AOT deployment

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions