Public excerpt
Locked
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…
About this 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”.
Example output
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…
Details
- Model
- DeepSeek
- Prompt language
- English
- Who it's for
- Backend developers and tech leads chasing intermittent bugs that only appear under load
- Length
- ~763 tokens (estimate)
- Delivered as
- Prompt text, shown online after purchase
- Category
- Code & Development
Reviews
No reviews yet. Only buyers of this prompt can leave one.