Stream: wg-ffi-unwind

Topic: Catching foreign exceptions


Amanieu (Oct 28 2019 at 16:31, on Zulip):

After thinking about it for a bit, there's a huge issue with catching foreign exceptions.

Amanieu (Oct 28 2019 at 16:31, on Zulip):

The exception object is only live inside the catch block. In Rust, this catch block is located entirely within intrinsics::try.

Amanieu (Oct 28 2019 at 16:33, on Zulip):

Basically if you want to be able to rethrow the foreign exception, this has to be done inside the catch block.

Amanieu (Oct 28 2019 at 16:33, on Zulip):

Otherwise the only thing you can do is return a "some foreign exception happened" error that you can't rethrow.

Kyle Strand (Oct 28 2019 at 16:40, on Zulip):

Sounds like either a new library function or a new syntax construct would be required for useful interaction with foreign exceptions, then.

Kyle Strand (Oct 28 2019 at 16:42, on Zulip):

In any case, catching foreign exceptions is currently outside the scope of the project group: https://rust-lang.zulipchat.com/#narrow/stream/210922-wg-ffi-unwind/topic/meeting.20time/near/178413258

Amanieu (Oct 28 2019 at 16:43, on Zulip):

Well there are some implications: since foreign exceptions allow you to unwind through catch_unwind silently, unsafe code needs to ensure that they do not use catch_unwind to maintain safety and instead use drop guards.

Kyle Strand (Oct 28 2019 at 16:51, on Zulip):

That's true. Though since foreign exception behavior in Rust isn't yet defined, catch_unwind should really be thought of as catch_panic (and in my opinion it was misnamed).

gnzlbg (Oct 28 2019 at 18:12, on Zulip):

These are some of the reasons for why I thought that maybe it would be more conservatibe for catch_unwind to abort on foreign exceptions at best

nikomatsakis (Oct 28 2019 at 20:17, on Zulip):

This is a really interesting question

nikomatsakis (Oct 28 2019 at 20:18, on Zulip):

I think @Kyle Strand that it'd be great to collect notes on this into the repo

nikomatsakis (Oct 28 2019 at 20:19, on Zulip):

I am imagining that we should basically have "in progress summaries" on key questions

Kyle Strand (Oct 28 2019 at 20:20, on Zulip):

I am imagining that we should basically have "in progress summaries" on key questions

That seems good as a way of organizing the "discussion summaries" section.

Last update: Nov 15 2019 at 09:40UTC