Rendered at 10:43:43 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
renehsz 2 days ago [-]
IMO Mutex poisoning is a symptom of the unfortunate decision to unwind panics by default, instead of the much more sane panic="abort".
There are two kinds of errors: Those that you expect to happen in production and should therefore be handled explicitly. And those that should never happen in production and should therefore simply crash the process.
Any sufficiently important production system needs to be able to recover from process crashes anyway (all code runs on physical hardware after all, so in rare instances it could crash despite your code being 100% correct).
If you decide to also try to recover from panics, that introduces another failure recovery mechanism that adds complexity despite being largely redundant. It's easy to get wrong, extremely cumbersome to test and verify, etc.
There can be many unfortunate consequences of the deeply misguided idea of unwinding panics and, worse still, attempting to recover from them, mutex poisoning is just one of them.
charleslmunger 5 days ago [-]
Why does poisoning require a penalty on the uncontended fast path? Using a bit within the futex word would make the acquire operation fail, directing to the show path where extra work can be done without cost.
manwe150 2 days ago [-]
Agreed. As much as poisoning has its problems, the article seems to barely touch on the main issues with it, like the cost of checking the return value penalizing callers that don’t just discard the result (because rust doesn’t have a zero-cost exception like c++) due to the added branch potentially doubling the cost of an uncontended lock; and once poisoned, it’s unclear why you never want to be able to do any introspection of the failed state afterwards to try to recover or report it
Panzerschrek 2 days ago [-]
Yet another example showing, that handling panic is a bad design decision. It adds so much complexity into the language and degrades performance in the majority of use-cases, since very little projects actually rely on panic being recovered.
It would be better to handle panic as termination of the whole process. Ideally it can be achieved by single instruction like ud2 allowing the OS doing the job.
There are two kinds of errors: Those that you expect to happen in production and should therefore be handled explicitly. And those that should never happen in production and should therefore simply crash the process.
Any sufficiently important production system needs to be able to recover from process crashes anyway (all code runs on physical hardware after all, so in rare instances it could crash despite your code being 100% correct).
If you decide to also try to recover from panics, that introduces another failure recovery mechanism that adds complexity despite being largely redundant. It's easy to get wrong, extremely cumbersome to test and verify, etc.
There can be many unfortunate consequences of the deeply misguided idea of unwinding panics and, worse still, attempting to recover from them, mutex poisoning is just one of them.
It would be better to handle panic as termination of the whole process. Ideally it can be achieved by single instruction like ud2 allowing the OS doing the job.