PoisonError: poisoned lock: another task failed inside Rust Origin: Application & API OSI layer 7 · Application Last updated 5 Nov 2026

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.

Exact message you may see PoisonError { .. }called `Result::unwrap()` on an `Err` value: PoisonError { .. }poisoned lock: another task failed insidePoisonError poisoned lock another task failed insidethread panicked: PoisonError
Seen on: Rust

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

  1. Fix the root-cause panic that poisoned the lock
  2. Recover: mutex.lock().unwrap_or_else(|e| e.into_inner())
  3. Consider parking_lot::Mutex (no poisoning) when appropriate

Detailed fix by platform

Rust

  1. let guard = m.lock().unwrap_or_else(|poisoned| poisoned.into_inner());

How to diagnose

  1. Root cause — First panic?
  2. State — Still valid?
  3. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

panic: already borrowed: BorrowMutError — Rust: thread 'main' panicked at src/main.rs:8:9: already borrowed: BorrowMutError / already mutably borrowed: BorrowError (Rust)panic: already borrow…panic: attempt to divide by zero — Rust: thread 'main' panicked at src/main.rs:3:13: attempt to divide by zero (Rust)panic: attempt to div…panic: attempt to subtract with overflow — Rust: thread 'main' panicked at src/main.rs:4:13: attempt to subtract with overflow (Rust)panic: attempt to sub…panic: called Option::unwrap() on a None value — Rust: thread 'main' panicked at src/main.rs:4:20: called `Option::unwrap()` on a `None` value (Rust)panic: called Option:…panic: called Result::unwrap() on an Err value — Rust: thread 'main' panicked at src/main.rs:5:36: called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit } (Rust)panic: called Result:…panic: index out of bounds: the len is N but the index is M — Rust: thread 'main' panicked at src/main.rs:5:5: index out of bounds: the len is 3 but the index is 3 (Rust)panic: index out of b…thread 'main' has overflowed its stack (SIGABRT) — Rust: thread 'main' has overflowed its stack — fatal runtime error: stack overflow (Rust)thread 'main' has ove…PoisonErr…

Explore the map of this error Full error map →

🧠 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.