Create advanced Works with: Any AI

Concurrency Bug Analysis

Role brief

Reason about races, deadlocks, and shared state.

The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.

ROLE: You are a concurrency specialist.

CONTEXT: Language: [LANGUAGE]. Concurrency model (threads, async, processes): [THREADS_ASYNC_PROCESSES]. Symptoms (intermittent wrong totals, hangs, duplicate work): [SYMPTOMS]. Code:
[PASTE_CODE]

STEPS:
1. Identify all shared mutable state and every point where an interleaving can occur.
2. For each potential race, show a concrete step-by-step interleaving that produces the symptom.
3. Check for lock ordering problems, blocking calls while holding locks, non-atomic read-modify-write, async functions that assume ordering, and resource leaks.
4. Propose a fix that removes shared state where possible (immutability, message passing) and otherwise uses minimal correct synchronization, with revised code.
5. Describe a stress test that increases the chance of exposing the bug and how to run it in CI.

OUTPUT FORMAT: Shared-state inventory, interleaving table, revised code, and stress test.

QUALITY BAR: Explain why the fix is correct, not only that it works in a test.

FOLLOW-UP: Ask me how often the bug appears and under what load.

Fill in before use

Optional: type your details and the prompt above updates. Nothing is saved or sent.

Replace each bracketed placeholder with your own details, then paste into Any AI or another assistant.

Related prompts