Skip to content

GC: preserve actively resumed generator ownership across moving safepoints #791

Description

@chrisbbreuer

Parent: #790. Related: #786, #787, #340, #349.

The #790 actual moving-GC witness reaches a native numeric safepoint from inside a synchronously resumed generator. The next resume then throws TypeError: generator is already running. The candidate unit transcript points to genResume resume_mutex.tryLock. Declaration-only tests pass.

Code audit: Generator embeds its resume mutex and Exec; genResume retains the Generator pointer and saved caller Environment/Values in native locals across execLoop. The relocation binding currently permits every young cell to move. Moving an actively borrowed generator copies the held mutex/inline Exec, while native cleanup and gc_execs can still name the old payload. The native caller restoration copies also lack precise rewrite slots.

Required fix: give the active native resume lifetime an explicit per-cell relocation/ownership ruling, preserve precise saved caller roots, and keep dormant generators relocatable. Do not disable moving GC, suppress the error, clear a copied mutex, or weaken the test. Verify actual movement of the surrounding graph, repeated next/throw/return and reentrancy, failure cleanup, and TSan. Audit the corresponding async native-borrow boundary separately; Promise/job implementation work remains with its owner.

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