Race condition and deadlock hunt with step-by-step thread interleavings

par fidji DeepSeek Anglais ~763 tokens
Extrait public Verrouillé
Shared-state inventory, atomicity assumptions marked at every await or lock, then a proof per bug: Step | Task | Operation | Local values | Shared state, with real starting values and the wrong final result. Wait-for graph for deadlocks, fix re-run on the same trace…

À propos de ce prompt

Finds lost updates, check-then-act bugs and deadlocks in concurrent code (threads, async tasks, several servers, database transactions). Each bug is only reported with a concrete interleaving trace that shows the wrong final value, then the fix is re-run on the same trace. Built for DeepSeek because the value lies in its explicit, checkable step-by-step reasoning: you can follow every interleaving instead of trusting a vague “this might be unsafe”.

Exemple de résultat

Fourni par l'auteur
SHARED STATE | accounts.balance | read in withdraw(), line 12 | written line 15 | none | any request handler | BUG 1 — Lost update in withdraw() — CONFIRMED Start: balance = 100. T1 withdraws 30, T2 withdraws 50. Invariant: final = 100 − 30 − 50 = 20. | Step | Task | Operation | Local | Balance after | | 1 | T1 | SELECT balance | b1 = 100 | 100 | | 2 | T2 | SELECT balance | b2 = 100 | 100 | | 3 | T1 | UPDATE balance = b1 − 30 | — | 70 | | 4 | T2 | UPDATE balance = b2 − 50 | — | 50 | Result 50 instead of 20: T1’s withdrawal is lost. Fix: UPDATE accounts SET balance = balance − :amount WHERE id = :id AND balance >= :amount, then check affected rows = 1. Re-run: step 3 → 100 − 30 = 70; step 4 → 70 − 50 = 20 ✓ BUG 2 — Deadlock in transfer() — CONFIRMED transfer(A, B): lock A → lock B. transfer(B, A): lock B → lock A. Wait-for graph: T1 waits for T2 (B), T2 waits for T1 (A) → cycle. Fix: always lock the account with the lower id first…

Fiche technique

Modèle
DeepSeek
Langue du prompt
Anglais
Pour qui
Backend developers and tech leads chasing intermittent bugs that only appear under load
Longueur
~763 tokens (estimation)
Format livré
Texte du prompt, affiché en ligne après achat

Avis

Réservés aux acheteurs

Aucun avis pour l'instant. Seuls les acheteurs de ce prompt peuvent en laisser un.

Signaler ce prompt