Skip to content

Threads: preserve async condition completion through Worker termination and mid-GC cleanup #792

Description

@chrisbbreuer

Parents: #482, #502. Related: #478, #727, #791.

Linux scheduled CI on 81ce859 failed the tsan-threadfuzz-midgc gate: https://github.com/zig-utils/zig-js/actions/runs/33102091424/job/98622344507

Command: THREADFUZZ_SEED_TIMEOUT_MS=300000 zig build threadfuzz -Dtsan=true -Dfuzz-midgc=true -Dfuzz-iters=2 (Zig 0.17.0-dev.1818+7051f8e73).

Exact failure: seed 2, worker terminate/condition check threw Throw: Error: bad worker terminate/condition cond score 0. Final denominator: 90 programs from seed 1, 1 failure. This is a functional assertion in a sanitizer-enabled run, not a reported ThreadSanitizer data race.

The runWorkerTerminateConditionAsyncCleanupInterleavingKind witness in conformance/threadfuzz.zig registers a Lock.asyncHold -> Condition.asyncWait -> reacquire continuation, confirms readiness, applies mid-GC pressure, notifies under the lock, throws to trigger cleanup, then drains the run loop. The expected condition completion score remains zero. Determine whether the continuation, reacquisition, or cleanup/drain ownership is lost; do not infer the cause from this assertion alone.

Acceptance: reproduce the exact seed and lifecycle; preserve precise live roots and exactly-once notification/reacquire/completion; verify both success and exception cleanup with native job/queue ownership; pass normal and TSan mid-GC gates without added polling delays, weakened assertions, extra unconditional drains, suppression, or disabled GC.

Implementation belongs with the ongoing native stack/queue/job and Worker/Promise lifecycle work. The environment declaration change (#790) does not modify that implementation.

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