Description
What is the result of using setjmp
in C, entering rust code, then calling longjmp, either from Rust, or after first returning into C
. Is this considered undefined behaviour or defined behaviour.
Because of Pin
(and likely others, things like replace_with
), this cannot be sound in general, but there is a question of whether it is considered immediately undefined behaviour or whether it is defined in Rust.
This intersects with @rust-lang/wg-ffi-unwind. From https://rust-lang.zulipchat.com/#narrow/stream/210922-project-ffi-unwind/topic/cost.20of.20supporting.20longjmp.20without.20annotations and https://rust-lang.zulipchat.com/#narrow/stream/210922-project-ffi-unwind/topic/longjmp.20rules the likely answer is "Undefined Behaviour" even through frames without destructors/catch_unwind.
In addition to determining the desired behaviour, we should consider what guarantees we've made that would make longjmp
unsound (beyond Pin
).
(Cc prior broader discussion: #211)