Stream: project-ffi-unwind

Topic: Catching foreign exceptions


view this post on Zulip Amanieu (Oct 28 2019 at 16:31):

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

view this post on Zulip Amanieu (Oct 28 2019 at 16:31):

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

view this post on Zulip Amanieu (Oct 28 2019 at 16:33):

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

view this post on Zulip Amanieu (Oct 28 2019 at 16:33):

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

view this post on Zulip BatmanAoD (Kyle Strand) (Oct 28 2019 at 16:40):

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

view this post on Zulip BatmanAoD (Kyle Strand) (Oct 28 2019 at 16:42):

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

view this post on Zulip Amanieu (Oct 28 2019 at 16:43):

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.

view this post on Zulip BatmanAoD (Kyle Strand) (Oct 28 2019 at 16:51):

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).

view this post on Zulip gnzlbg (Oct 28 2019 at 18:12):

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

view this post on Zulip nikomatsakis (Oct 28 2019 at 20:17):

This is a really interesting question

view this post on Zulip nikomatsakis (Oct 28 2019 at 20:18):

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

view this post on Zulip nikomatsakis (Oct 28 2019 at 20:19):

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

view this post on Zulip BatmanAoD (Kyle Strand) (Oct 28 2019 at 20:20):

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 updated: Jan 26 2022 at 08:46 UTC