Skip to content- Sources: primary
- Summary: Armin Ronacher's post backs the Rust libs team discussion on making non-poisoning locks the default in the next edition. He notes that PoisonError holds the guard, so an innocent m.lock()? inside error conversion keeps the mutex locked and deadlocks, as seen in cc-switch and ox-embed-server. He cites RLS, a Neon safekeeper and Mozilla application-services, where PoisonError reached rank 5 in crash stats before the team moved to parking_lot, plus poisoned statics breaking test suites in cargo, deno, polars and rustc. Tokio, wasmtime, crossbeam-channel and tracing-subscriber all ignore poisoning, and std ignores it in stdio, panic capture and the backtrace lock.
- Why it matters: If you catch panics anywhere, in tokio tasks, thread pools or FFI boundaries, lock().unwrap() turns one panic into a process that stays up and fails every later lock.
- Background: When Rust code panics while holding a std::sync::Mutex, the mutex is poisoned and every later lock() returns PoisonError, on the theory that the panic may have left broken invariants behind. The flag could not even be cleared until clear_poison arrived in Rust 1.77, nine years after the feature landed. With panic = abort the question never arises, and parking_lot has never implemented poisoning. RefCell and OnceLock do not poison, while LazyLock poisons permanently.
- Follow-up: A libs team decision on stabilizing std::sync::nonpoison and making it the edition default