Skip to content

GC: release child-realm native graphs cleanly after active moving calls #831

Description

@chrisbbreuer

Discovered while isolating #827 from native realm restoration.

Exact local witness: retain only a foreign realm's Array.of native, drop the realm global handle, and invoke it with a constructor whose body triggers the deterministic moving safepoint. The operation completes correctly in both forced modes, but the allocator gate reports six leaked allocations per context from the child realm's WebAssembly.instantiateStreaming native property metadata (cold state, attribute map, and owned keys). Keeping an explicit child-realm prototype/global reference avoids the leak, so this is a realm graph/finalization ownership defect rather than Array result semantics.

The issue is separate from #827: the Array operand/result roots can be correct while the now-unreachable child realm tears down incompletely.

Acceptance:

  • Add the exact retained-native/dropped-global moving witness in both forced modes.
  • Identify and repair the missing trace, relocation, or finalization ownership edge; no pinning, leak suppression, GC disabling, or retained-global workaround.
  • Prove zero allocator leaks and no double-finalization under repeated moving/full collection.
  • Run unsuppressed TSan, full native tests, and relevant realm/GC stress coverage.

Related: #827 and parent #465.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions