embedonomicon icon indicating copy to clipboard operation
embedonomicon copied to clipboard

New topic: Unwinding

Open japaric opened this issue 7 years ago • 6 comments

We should add a topic about implementing your own panic_unwind crate. I know this involves the "eh_personality" lang item but I have never done this myself. If someone has a working example that would be very useful!

As unwinding depends on an unstable feature this topic is not a blocker for the edition release.

japaric avatar Aug 20 '18 11:08 japaric

The "Writing an OS in Rust" blog has a short example. Redox OS also has a more thorough implementation. Not sure about embedded Rust projects, though.

ianjfrosst avatar Oct 02 '18 13:10 ianjfrosst

On a related note: has anyone considered writing an unwinder in Rust? Now that compiler-builtins is largely finished, this seems one of the last pieces of C dependencies for many platforms.

jethrogb avatar Dec 07 '18 11:12 jethrogb

Just curious: What's the use case for unwinding in embedded scenarios?

therealprof avatar Dec 07 '18 12:12 therealprof

@therealprof running unit tests on the device. Even with a CTF (Custom Test Framework) that uses Result::Err to signal errors panics can still occur during any unit test (e.g. debug_assert!) and that would cause the test runner to stop (e.g. panic-halt). With catch_unwind functionality it would be possible to catch the panic, mark the unit test as failed and continue to run the unit tests.

japaric avatar Feb 08 '19 18:02 japaric

Makes sense, thanks for the explanation.

therealprof avatar Feb 08 '19 21:02 therealprof

it's super cursed but i think it'd be useful to document the implications of unwinding across ffi boundaries for c/rust interop and supporting the piecewise approach to moving to rust.

ideally they never happen, but, when they do on a desktop the errors are incomprehensible, and i haven't been bold enough to see what happens in an embedded context.

ryankurte avatar May 09 '19 21:05 ryankurte