Is it possible for data low in the stack to propagate upwards through the stack before function return? It seems like if this were to be an issue, you would need to move into something parent gives you, at which point you no longer have ownership and unwinding won't destroy it.
It seems like the lifetime system prevents this from being a problem. I think Rust *could* have catchable exceptions, you just wouldn't be allowed to use anything that can throw when constructing a value. That way, everything is fully constructed when an exception happens, so destructors can never run on inconsistent state and resources won't leak. Maybe there's something I'm missing, though. On Tue, Nov 12, 2013 at 2:07 PM, Kevin Ballard <[email protected]> wrote: > 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 _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
