Oriel — AI & technology worth noticing, every day.

In defense of lock poisoning in Rust

Web page · https://sunshowers.io/posts/on-poisoning

First seen by Oriel on .

AI summary

This essay argues that Rust lock poisoning should remain the default because unexpected panic or cancellation during critical sections can silently corrupt mutex-guarded invariants.

  • Mutex poisoning marks a lock when its guard is released during a panic, causing later lock attempts to return PoisonError rather than exposing potentially inconsistent data.
  • Unjoined panics in non-main threads can otherwise be easy to miss, leaving guarded state logically corrupted while the process exits successfully.
  • Poisoning is conservative: reads, counter updates, and carefully unwind-safe structures may remain valid, but future code changes can introduce invariant violations.
  • The author connects poisoning to async future cancellation, citing repeated mutex invariant violations and arguing that detection is more important than recovery or availability.
  • Poisoning is advisory because callers can recover the underlying data and clear the poison bit in Rust 1.77 and above.

#rust #mutexes #concurrency #async cancellation

Generated by gpt-5.6-sol. Check the original for details.

Metric trends

Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained

Points

Score reported by the source.

  • Lobsters: 33, latest observation ; +32 over observed period since

Comments

Comment count reported by the source.

  • Lobsters: 16, latest observation ; +15 over observed period since

Aliases

SourceExternal IDURL
Lobsterswpylechttps://sunshowers.io/posts/on-poisoning/ Read discussion