Works with the AI tools you already use

    CClaude CodeCCursorCCodex CLIGGitHub CopilotGGemini CLI+17 more

    Repair Lost Wakeup Races

    by Mariusz Wrzeszczynski

    1

    Repair lost wakeups in condition variables, worker queues, shutdown gates, wait/notify loops, and hand-built events.

    Secure checkout via Stripe

    0 installsSecurity scanned

    See it in action

    You say

    Our C++ worker pool checks queue.empty() before acquiring the condition_variable mutex. A producer can enqueue and notify between that check and wait(), leaving the worker asleep until unrelated work arrives. Shutdown occasionally hangs for the same reason. Repair locally with deterministic barriers and ThreadSanitizer tests. Preserve queue capacity, worker count, and scheduling policy; do not replace the wait with polling.

    Your agent does

    Lost-wakeup window found. The worker checks queue state outside the condition mutex, then a producer enqueues and notifies before the worker actually waits. The repair makes the queue predicate authoritative under one lock, waits in a predicate loop, notifies after transition, and validates notify-before-wait and spurious-wake orderings with deterministic barriers.

    What you get

    Prevent workers from sleeping when tasks are pending in the queue.Fix shutdown hangs caused by missed termination signals.Eliminate flaky concurrency tests that depend on arbitrary sleeps.Audit and unify mutex ownership across split-lock state transitions.

    About this skill

    The problem

    Race conditions in multi-threaded code often lead to intermittent hangs where workers sleep despite work being available. These bugs are notoriously difficult to reproduce and often "solved" with fragile sleeps that mask the underlying synchronization failure.

    What it does

    • Identifies lost notifications where signals occur between checking state and entering a wait block.
    • Enforces wait-loop discipline by converting incorrect if checks into robust predicate loops.
    • Audits lock ownership to ensure state predicates and notifications share the same synchronization contract.
    • Removes reliance on notification counting and replaces sleep-based tests with deterministic barriers.
    • Implements observability for waiter counts, transition reasons, and shutdown generations.

    Frameworks & tools

    Works with low-level synchronization primitives including condition variables, monitors, mutexes, latches, and atomic state guards in C++, Java, Go, Rust, and Python.

    Why this beats prompting it yourself

    LLMs often suggest polling or increasing timeouts when faced with deadlocks. This skill follows a rigorous concurrency safety protocol that treats notifications as hints rather than durable events, ensuring the state predicate remains the single source of truth without changing your scheduling policy.

    Use cases

    • Fixing intermittent CI hangs during service shutdown sequences.
    • Resolving worker starvation in custom thread pools or task queues.
    • Stabilizing flaky tests that currently rely on time.Sleep to pass.
    • Standardizing synchronization contracts across legacy multi-threaded modules.

    Known limitations

    Does not modify queue capacity, fairness policies, or worker counts. Requires access to the repository files to build a synchronization register.

    How to install

    Drop the file into your AI Agent. Works with Claude, Cursor, ChatGPT, and 20+ more.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    30-day refund

    Not a fit? Get your money back

    Frequently Asked Questions

    Popular in AI Agents & LLM Ops