Michael-F-Bryan / rust-ffi-guide

A guide for doing FFI using Rust
https://michael-f-bryan.github.io/rust-ffi-guide/
Creative Commons Zero v1.0 Universal
282 stars 18 forks source link

Unwinding Problem #49

Open Michael-F-Bryan opened 6 years ago

Michael-F-Bryan commented 6 years ago

Problem 2 (link) is about what happens when some function being called from C++ panics. The solutions section should explain why we get a segfault (or UB) when Rust functions panic, why unwinding across the FFI barrier is UB, and what's going on behind the scenes which results in the behaviour we see. It should also mention how you prevent accidentally panicking across the FFI barrier (catch_unwind).