After some recent discussion on the topic of mutex poisoning and notably a blog post that I thought was interesting, thoughtful, exhaustive, yet completely disagreed with, I wanted to comment on the debate myself. To me, poisoning-by-default is one of biggest mistakes that were made in the language, next to some others that are a story for a different time.
I guess I would have thought panic would trigger other threads to abort as well. Admittedly I haven’t really done any multithreading in Rust. I was thinking it was more like
exit(status)in C/C++ that immediately terminated the entire process. Exception unrolling in general I feel is something that should be avoided if you care at all about error conditions.If panics are isolated to one thread, then I guess mutex poisoning is a better default error case than a deadlock where the process never exits. An entirely independent thread might still be unaware the rest of the program has crashed though.
Panics in Rust default to stack unwinding, which I believe is similar to how exceptions work in C++. I don’t believe an unhandled exception in C++ kills other threads either? Could be wrong.
Panics can also be configured to instead abort the process immediately, which is the exit(status) way. Obviously with that solution you can never observe a poisoned mutex so you would never need a poisoning mutex in that situation anyway.