Right now, Rust does not support catching task failure from within a task, it 
only supports preventing task failure from cascading into other tasks. My 
understanding is that this limitation is done because of safety; if a task 
unwinds through a few frames of code, and then stops unwinding, data structure 
invariants may have been broken by the unwinding, leaving the task in an unsafe 
state. Is this correct?

Given this assumption, my worry now is about task unwinding outside of the 
control of Rust. Namely, if I’m using Rust to write a library with extern “C” 
functions, or I’m providing callbacks to C code from within Rust, (and my Rust 
code calls back into C at some point), then it’s very possible for the called C 
code to throw an exception that is then caught in the calling C code a few 
frames up. The net effect is that the thread will unwind through my Rust code, 
but it will then be caught before unwinding any further, potentially leaving 
any data structures in an invalid state (assuming that there’s still Rust code 
higher up on this same stack that cares).

Has this been considered before? Is this actually a danger or am I just being 
paranoid?

-Kevin
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to