zlacker

[parent] [thread] 4 comments
1. lifthr+(OP)[view] [source] 2022-10-02 16:40:58
Panic corresponds to a potential logic bug. If you have a logic bug, you already risk its consequences even if the panic didn't happen. As long as panic can be caught (and in Rust, it's indeed the case) it is safer than the alternative.
replies(1): >>hegels+Ze1
2. hegels+Ze1[view] [source] 2022-10-03 01:25:44
>>lifthr+(OP)
1. As far as i'm aware there's no way to reliably catch all panics. catch_unwind does not catch all panics. 2. The whole point is that consequences of a panic are worse than the consequences of memory corruption. That's how the kernel was designed. There was an explicit design decision not to kernel panic in every situation where a logic error occurs.
replies(1): >>lifthr+Sr1
◧◩
3. lifthr+Sr1[view] [source] [discussion] 2022-10-03 03:23:50
>>hegels+Ze1
There are tons of edge cases with panics, e.g. panic can trigger a destructor that can panic itself, or unwinding may cross a language boundary which may not be well defined, but to my knowledge `catch_unwind` does catch all panics as long as unwinding reliably works. That disclaimer in the `catch_unwind` documentation only describes the `panic = abort` case.

And I thought it was clear that kernel panic is different from Rust panic, which you don't seem to distinguish. Rust panic doesn't need to cause a kernel panic because it can be caught earlier.

replies(1): >>hegels+Gv1
◧◩◪
4. hegels+Gv1[view] [source] [discussion] 2022-10-03 04:11:43
>>lifthr+Sr1
Obviously rust panic is not the same as a kernel panic. What you're taking for granted is that just because rust can catch a panic that it will. A simple overflow can cause a panic. When this happens, the panic might be caught before the kernel panics, but by then the program is probably already in an undefined state. It also might not be caught at all, and cause an actual kernel panic.
replies(1): >>lifthr+Fy1
◧◩◪◨
5. lifthr+Fy1[view] [source] [discussion] 2022-10-03 04:47:14
>>hegels+Gv1
The program is in a defined but undesirable state, both when panic occurred in Rust and when a "simple" uncontrolled overflow happened in C (provided that the compiler is configured to not treat it as an UB, otherwise it'd be worse). And anyone doing Rust-C interop already has to be conscious about the language boundary, which happens to be a perfect place to catch Rust panics.
[go to top]