---
title: "In defense of lock poisoning in Rust · sunshowers"
url: https://daily.dev/posts/in-defense-of-lock-poisoning-in-rust-sunshowers-gbd3raimp
source_url: https://sunshowers.io/posts/on-poisoning/
type: article
source: "Lobsters"
published: 2025-12-02T22:51:06.608Z
updated: 2025-12-02T22:51:28.888Z
tags: ["rust"]
reading_time: 23
upvotes: 22
comments: 1
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# In defense of lock poisoning in Rust · sunshowers

**[Lobsters](https://daily.dev/sources/lobsters)** · 23 min read · 22 upvotes · 1 comments

## Summary

Lock poisoning in Rust detects when a thread panics while holding a mutex, preventing silent data corruption. When a panic occurs during a critical section, the mutex is marked poisoned, causing subsequent lock attempts to fail. This mechanism is crucial because panics can leave shared data in inconsistent states. The author argues against proposals to remove poisoning by default, advocating instead for making lock() automatically panic on poison while maintaining safety. The piece explores how unexpected cancellations—both from panics and async future cancellations—can violate mutex invariants, and why detection through poisoning is more important than recovery.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://sunshowers.io/posts/on-poisoning/>

## Community discussion

Top comments from developers on daily.dev.

**@akkitto** · 0 upvotes

> Very interesting detailed article. Pleasure to read. Agreeing with its notion, as well.

## Similar posts on daily.dev

- [Rust Prevents Data Races, Not Race Conditions](https://daily.dev/posts/rust-prevents-data-races-not-race-conditions-fjfi1lvd3) · corrode · 9 upvotes · 0 comments
- [To panic or not to panic](https://daily.dev/posts/to-panic-or-not-to-panic-bzeul9gmg) · Nick Cameron · 0 upvotes · 0 comments
- [Cancelling async Rust ꞏ sunshowers](https://daily.dev/posts/cancelling-async-rust-sunshowers-2inz8rola) · Lobsters · 1 upvotes · 0 comments
- [Hardening Rust Code For Production](https://daily.dev/posts/hardening-rust-code-for-production-lyax4vift) · corrode · 1 upvotes · 0 comments

---

Tags: [#rust](https://daily.dev/tags/rust)

[View this post on daily.dev](https://daily.dev/posts/in-defense-of-lock-poisoning-in-rust-sunshowers-gbd3raimp)
