Rust: thread 'main' panicked: called `Result::unwrap()` on an `Err` value: PoisonError { .. } — poisoned lock: another task failed inside
A thread panicked while holding a Mutex/RwLock, so the lock is "poisoned" and lock().unwrap() panics for others.
PoisonError { .. }called `Result::unwrap()` on an `Err` value: PoisonError { .. }poisoned lock: another task failed insidePoisonError poisoned lock another task failed insidethread panicked: PoisonError Meaning
Fix the original panic first (it happened in another thread: look earlier in the log). Then either propagate (lock().unwrap() is intentional to fail fast) or recover with lock().unwrap_or_else(|e| e.into_inner()) if state is still valid. parking_lot::Mutex doesn't poison.
Common causes
- A thread panicked while holding the guard
unwrap()on a previously panicked mutex- Panics inside critical sections (indexing, unwrap)
- Test threads sharing global mutexes
- Async tasks panicking with guards
⚡ Quick fix
- Fix the root-cause panic that poisoned the lock
- Recover:
mutex.lock().unwrap_or_else(|e| e.into_inner()) - Consider
parking_lot::Mutex(no poisoning) when appropriate
Detailed fix by platform
Rust
let guard = m.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
How to diagnose
- Root cause — First panic?
- State — Still valid?
- Alternative — parking_lot?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- panic: already borrowed: BorrowMutError Rust: thread 'main' panicked at src/main.rs:8:9: already borrowed: BorrowMutError / already mutably borrowed: BorrowError
- panic: attempt to divide by zero Rust: thread 'main' panicked at src/main.rs:3:13: attempt to divide by zero
- panic: attempt to subtract with overflow Rust: thread 'main' panicked at src/main.rs:4:13: attempt to subtract with overflow
Most viewed in Rust
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026