Add some mechanism for catching structured exceptions on Windows

9ba9de3
Opened by Jeff Muizelaar at 2020-12-26 15:21:16

There are a number of places where we are forced to catch these exceptions in Gecko (see MOZ_SEH_TRY). The usual reason is for handling some bug in code that we have no control over.

Structured exceptions are also used for naming threads on Windows so it would be nice to have that too.

  1. Do you have any idea when this will be supported? Not being able to catch structured exceptions makes it impossible to use file views which throw an exception when an IO error occurs (including network errors when the file is on a network share).

    What happens if an exception is thrown right now? I assume my process will just die?

    Are there well-known hacks to work around this (inline assembly, abusing panic::catch_unwind, anything) available?

    Benedikt Radtke at 2020-09-01 15:13:45

  2. Do you have any idea when this will be supported? Not being able to catch structured exceptions makes it impossible to use file views which throw an exception when an IO error occurs (including network errors when the file is on a network share).

    What happens if an exception is thrown right now? I assume my process will just die?

    Are there well-known hacks to work around this (inline assembly, abusing panic::catch_unwind, anything) available?

    AFAIK, the only practical workaround (now) is writing a C function which has the required __try/__catch block to handle the exception and returns the result in a Rust-compatible structure (or something like that), and compiling it with MSVC and linking to it in your crate.

    mzji at 2020-12-26 15:21:16