pull/365/head
Kyle Strand 3 years ago
parent 4f7e15da74
commit 8a9684abc3

@ -723,19 +723,19 @@ No `transmute` required!
Its important to be mindful of unwinding when working with FFI. Each Its important to be mindful of unwinding when working with FFI. Each
non-`Rust` ABI comes in two variants, one with `-unwind` and one without. If non-`Rust` ABI comes in two variants, one with `-unwind` and one without. If
you expect Rust `panic`s or foreign (e.g. C++) exceptions to cross an FFI you expect Rust `panic`s or foreign (e.g. C++) exceptions to cross an FFI
boundary, that boundary must use the appropriate `-unwind` ABI string, and you boundary, that boundary must use the appropriate `-unwind` ABI string. (Note
must not compile with `panic=abort`. that compiling with `panic=abort` will still cause `panic!` to immediately
abort the process, regardless of which ABI is specified by the function that
`panic`s.)
Conversely, if you do not expect unwinding to cross an ABI boundary, use one of Conversely, if you do not expect unwinding to cross an ABI boundary, use one of
the non-`unwind` ABI strings (other than `Rust`, which always permits the non-`unwind` ABI strings (other than `Rust`, which always permits
unwinding). If an unwinding operation does encounter an ABI boundary that is unwinding). If an unwinding operation does encounter an ABI boundary that is
not permitted to unwind, the behavior depends on whether the Rust code was not permitted to unwind, the behavior depends on the source of the unwinding
compiled with `panic=abort`: (Rust `panic` or a foreign exception):
* With `panic=unwind`, the process will safely abort. * `panic` will cause the process to safely abort.
* With `panic=abort`, the behavior is undefined. This is only possible with * A foreign exception entering Rust will cause undefined behavior.
foreign exceptions, since `panic` will always abort rather than unwind in
this case.
Note that the interaction of `catch_unwind` with foreign exceptions **is Note that the interaction of `catch_unwind` with foreign exceptions **is
undefined**, as is the interaction of `panic` with foreign exception-catching undefined**, as is the interaction of `panic` with foreign exception-catching
@ -841,7 +841,7 @@ fn main() {}
``` ```
Please note that [`catch_unwind`] will only catch unwinding panics, not Please note that [`catch_unwind`] will only catch unwinding panics, not
those who abort the process. See the documentation of [`catch_unwind`] those that abort the process. See the documentation of [`catch_unwind`]
for more information. for more information.
[`catch_unwind`]: ../std/panic/fn.catch_unwind.html [`catch_unwind`]: ../std/panic/fn.catch_unwind.html

Loading…
Cancel
Save