- Unlike ABIs, there is no syntax for assigning attributes to function pointers. The ABI must be part of the type system so that callers of function pointers know whether or not the function may unwind.
- mark declarations in Rust
extern "C unwind" - Do not use
catch_unwindin calling code - compile w/
panic = unwind - Check compiler, linker, & platform documentation (TODO: expand on this)
- Re-test for every compiler update
- (TODO: other caveats?)
setjmp/longjmpacross Rust frames is currently intended to have well defined behavior as long as those frames do not contain destructors, although we don't have any documentation to that effect. See rust-lang/unsafe-code-guidelines#210 for more details.- When crossing frames that do contain destructors, the behavior of
longjmpis Undefined Behavior; conversely, a primary goal of defining cross-language unwinding behavior is to support crossing frames with destructors. - Rust does not have a concept of
Copyfor stack-frames, which would permit the compiler to check thatlongjmpmay safely traverse those frames. Such a language feature may be added in the future, but although it would be useful forlongjmp, it would not be useful for unwinding. - It should never be assumed that
dropwill be called for objects in intermediate frames traversed by alongjmp, but this may occur on certain platforms. Rust provides no guarantee either way (which is why this is considered Undefined Behavior). Cross-language unwind, however, will be defined such thatDropobjects whose frames are unwound are guaranteeddroped. - Unwinding across Rust frames when
panic = abortis currently undefined behavior, but we plan to define the behavior to cause the application toabort. The behavior ofsetjmp/longjmp, however, is independent of thepanicruntime. - unwinding involves the use of a personality function, which raises additional
cross-language compatibility concerns;
setjmp/longjmpdoes not.
- Ideally: none. However, if Rust's default unwinding mechanism changes, a
translation layer will be required to maintain the
C unwindABI. - One more concern is how
panic = abortwill be handled; please refer to the roadmap for details.