Re: [rust-dev] Danger of throwing exceptions through Rust code

2013-11-13 Thread Niko Matsakis
The interplay between exceptions and foreign code is a complicated topic. Here are some miscellaneous thoughts. 1. I don't believe there is any memory safety reason we could not support catchable exceptions in Rust. The main concern is more one of good design; it's difficult to recover

Re: [rust-dev] Danger of throwing exceptions through Rust code

2013-11-13 Thread Florian Weimer
* Daniel Micay: It's undefined behaviour for a C++ function to throw an exception past an `extern C` boundary I don't think this is true. Certainly GCC supports throwing from C as an extension (if the C side has been compiled with -fexceptions), and requires that non-throwing functions are

Re: [rust-dev] Danger of throwing exceptions through Rust code

2013-11-13 Thread Thad Guidry
In awe, Niko does a fantastic job of breaking things down. Give that guy a raise already. ;) And he brings the most important point of all in this discussion. Sometimes authors care and sometimes they don't Maybe the important distinction is how the author wraps the library, to bring about

[rust-dev] Danger of throwing exceptions through Rust code

2013-11-12 Thread Kevin Ballard
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

Re: [rust-dev] Danger of throwing exceptions through Rust code

2013-11-12 Thread Corey Richardson
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

Re: [rust-dev] Danger of throwing exceptions through Rust code

2013-11-12 Thread Alex Crichton
You're correct about the safeness of catching failure at a task boundary. Rust's invariants about spawning a task involve knowing a fair bit about what's allowable to share between a task boundary, and that allows us to reason about the failure unwinding to the task boundary being a safe operation

Re: [rust-dev] Danger of throwing exceptions through Rust code

2013-11-12 Thread Daniel Micay
On Tue, Nov 12, 2013 at 2:35 PM, Alex Crichton a...@crichton.co wrote: You're correct about the safeness of catching failure at a task boundary. Rust's invariants about spawning a task involve knowing a fair bit about what's allowable to share between a task boundary, and that allows us to

Re: [rust-dev] Danger of throwing exceptions through Rust code

2013-11-12 Thread Kevin Ballard
I guess I was being too vague when I said “C exceptions”, because you’re right, that’s not actually a specific thing. More concretely, I was thinking of either C++ exceptions, or Obj-C exceptions. One situation I was thinking of would be a rust library that exposes `extern “C”` functions.

Re: [rust-dev] Danger of throwing exceptions through Rust code

2013-11-12 Thread Daniel Micay
On Tue, Nov 12, 2013 at 9:42 PM, Kevin Ballard ke...@sb.org wrote: I guess I was being too vague when I said “C exceptions”, because you’re right, that’s not actually a specific thing. More concretely, I was thinking of either C++ exceptions, or Obj-C exceptions. One situation I was thinking

Re: [rust-dev] Danger of throwing exceptions through Rust code

2013-11-12 Thread Patrick Walton
On 11/13/13 12:06 PM, Daniel Micay wrote: It's completely possible to write safe bindings to a C++ library. The process involves wrapping the whole thing with `extern C` functions using catch blocks for any function possibly throwing an exception. Keep in mind that libraries already have to do