-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft for the "0th" RFC #11
Conversation
that do not contain destructors. At minimum, this group should take | ||
the behavior of longjmp into account; if it is easy to do, we may also | ||
introduce mechanisms or RFCs that help to specify the use of longjmp | ||
in particular cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this isn't really that related to longjmp
, although longjmp
exhibits this issue. As the text says, on these platforms, these longjmps are implemented using "native unwinds". The problem is that on these platforms "native unwinds" can behave differently, depending on, e.g., how they are thrown.
If this WG attacks the problem of how native unwinds behave in Rust, it would need to consider those potential differences in behavior.
I'm not sure how to word that into this section which appears more focused on the issue discovered while using rlua on windows.
permitted to unwind. The precise unwinding mechanism in use will | ||
depend on the target platform, but the intent is to match the | ||
mechanism used by other systems programming language implementations, | ||
such as C++. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
such as C++. | |
such as C++ or C with `-fexceptions`. |
* The **intent** of this ABI, however, is to permit Rust panics to | ||
be "translated" into a "native" unwinding mechanism, though | ||
precisely which is dependent on the target platform or other | ||
compiler options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which compiler options do you have in mind here ?
I think that the "native" unwinding mechanism is part of the target ABI, i.e., part of the target triple. So there should be no way to change it via compiler options, doing so requires a completely different target.
For example, on windows, the mingw targets specify the unwinding ABI as part of their triple in the MinGW C toolchains ...-mingw-seh
, ...-mingw-sjlj
, etc.
Currently, for Rust, the x86_64-pc-windows-gnu
and i686-pc-windows-gnu
use the SEH abi. If we wanted to use the SJLJ abi there, a different target triple, e.g., x86_64-pc-windows-gnu-sjlj
feels like a better idea, because not only the Rust part of the ABI implementation has to change, but we need to call the C compilers and linkers with different flags, link different platform libraries that use this other ABI, etc.
There is the potential use case of being able to link both C libraries that use SEH and C libraries that use SJLJ in such a platform, but then "C unwind" isn't enough, because it doesn't let you specify which ABI to use. Instead of maybe trying to make "C unwind" fit this use case, I think it would be better to leave solving this problem to some other language feature, e.g., adding two platform specific ABIs on that target only, like "C SEH"
and "C SJLJ"
, or something like that. That kind of ABI information needs to propagate correctly through function pointers and such.
So I would change the text above to:
The intent of this ABI, however, is to permit Rust panics to
be "translated" into the "native" unwinding mechanism of the platform,
which is fixed by the platform target specification.
Note that this text is used below as well.
One meta-comment is that the RFC suggest that If we were to do that, the questions:
I don't think these questions are worth answering, and would prefer the RFC to not leave any room for those questions to appear. Specifying instead that |
Co-Authored-By: gnzlbg <[email protected]>
Co-Authored-By: gnzlbg <[email protected]>
|
||
* First, to modify Rust functions with the "C" abi to abort on unwinding, as proposed | ||
in [rust-lang/rust#52652]. | ||
* Second, to introduce the "C unwind" ABI, with virtually all details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Second, to introduce the "C unwind" ABI, with virtually all details | |
* Second, to introduce the target-specific "C unwind" ABI (available on some targets only), with virtually all details |
* The "project group" term is newly introduced, but it corresponds | ||
to a kind of working group -- one with the goal of fleshing out | ||
a particular proposal or completing a project. | ||
* We aim to specify how "C unwind" works on major platforms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* We aim to specify how "C unwind" works on major platforms | |
* We aim to specify how "C unwind" works on major platforms, adding support for new targets incrementally |
|
||
* First, to modify Rust functions with the "C" abi to abort on unwinding, as proposed | ||
in [rust-lang/rust#52652]. | ||
* Second, to introduce the "C unwind" ABI, with virtually all details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Second, to introduce the "C unwind" ABI, with virtually all details | |
* Second, to introduce the target-specific "C unwind" ABI (available on some platforms only), with virtually all details |
* The "project group" term is newly introduced, but it corresponds | ||
to a kind of working group -- one with the goal of fleshing out | ||
a particular proposal or completing a project. | ||
* We aim to specify how "C unwind" works on major platforms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* We aim to specify how "C unwind" works on major platforms | |
* We aim to specify how "C unwind" works on major platforms, adding support for new targets incrementally |
* We aim to specify how "C unwind" works on major platforms | ||
* Goal is to enable Rust panics to propagate across native frames | ||
* And perhaps to enable native exceptions to propagate across Rust frames | ||
* But not to allow catching or throwing native exceptions from Rust code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* But not to allow catching or throwing native exceptions from Rust code | |
* But we don't know at this point if the working group will end up allowing catching or throwing native exceptions from Rust code |
@acfoltzer I think something like this is what you meant ?
However, we do not guarantee such interop: this leaves room for | ||
platforms where unwinding is transmitted through a special return | ||
value or other such mechanism. (XXX do any such platforms exist? There | ||
is the C++ proposal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'm not sure about these two paragraphs. I suppose that this a defense against "unknown unknowns" but I understand "C unwind" as "the C ABI + unwinding", so I kind of expect it to be equivalent to "C" when -C panic=abort
, for example.
The C++ proposal is compatible with the C ABI, and there is also a C proposal for it that adds support for the same C++ feature to C without breaking the current call ABI (I'm not sure if it breaks the unwind ABI on some platforms though, but since the C standard doesn't have a concept of unwinding, it breaks nothing there at least).
Co-Authored-By: gnzlbg <[email protected]>
Co-Authored-By: gnzlbg <[email protected]>
Co-Authored-By: gnzlbg <[email protected]>
Superseded by #28 |
This draft includes the basic text for the 0th RFC. It has a few FIXMEs. The summary:
in [Abort instead of unwinding past FFI functions rust#52652].
(but not quite all) left as "to be determined".
be "translated" into a "native" unwinding mechanism, though
precisely which is dependent on the target platform or other
compiler options.
use the native mechanism, but this is explicitly not
required for the future.)
"C unwind" ABI, which captures their intentions. Their code is no more stable
than it was, but they are on the right path.
RFCs to flesh out the details of the "C unwind" ABI
to a kind of working group -- one with the goal of fleshing out
a particular proposal or completing a project.