-
Notifications
You must be signed in to change notification settings - Fork 1.6k
WIP: "C panic" ABI specifier #2753
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
Changes from 1 commit
d252881
beb20e3
4e892b1
513a86e
1d0cc81
c3588d4
42b7e2b
d5b3c95
b155874
cb4e853
e950faa
dab4e7f
233578e
8594404
8c78012
cdd2ab1
0908383
62e9a61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,75 @@ | ||||||||||
- Feature Name: `simple_unwind_attribute` | ||||||||||
- Start Date: 2019-08-29 | ||||||||||
- RFC PR: [rust-lang/rfcs#0000](https://github.com/rust-lang/rfcs/pull/0000) | ||||||||||
- Rust Issue: [rust-lang/rust#0000](https://github.com/rust-lang/rust/issues/0000) | ||||||||||
|
||||||||||
# Summary | ||||||||||
[summary]: #summary | ||||||||||
|
||||||||||
Provides an annotation to permit functions with explicit ABI specifications | ||||||||||
(such as `extern "C"`) to unwind | ||||||||||
|
||||||||||
# Motivation | ||||||||||
[motivation]: #motivation | ||||||||||
|
||||||||||
TODO | ||||||||||
|
||||||||||
- soundness & optimization | ||||||||||
- libjpeg/mozjpeg | ||||||||||
|
||||||||||
# Guide-level explanation | ||||||||||
[guide-level-explanation]: #guide-level-explanation | ||||||||||
|
||||||||||
TODO | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(The current verbiage is bad. Please suggest improvements.) I don't think we've yet reached consensus on whether to include the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes. |
||||||||||
|
||||||||||
# Reference-level explanation | ||||||||||
[reference-level-explanation]: #reference-level-explanation | ||||||||||
|
||||||||||
TODO: incorporate changes from discussion here: | ||||||||||
https://github.com/rust-lang/rust/pull/63909 | ||||||||||
|
||||||||||
By default, Rust assumes that an external function imported with extern "C" | ||||||||||
BatmanAoD marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
cannot unwind, and Rust will abort if a panic would propagate out of a Rust | ||||||||||
function exported with extern "C" function. If you specify the #[unwind] | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This verbiage could still be improved |
||||||||||
attribute on an extern "C" function, Rust will instead allow an unwind (such as | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
To be clarified: the annotation can be applied to either function definitions ( Without this annotation, what is the behavior supposed to be? I'm pretty sure that for maximum soundness, definitions should always abort and declarations should be assumed not to abort. Should declarations without
BatmanAoD marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
a panic) to proceed through that function boundary using Rust's normal unwind | ||||||||||
mechanism. This may potentially allow Rust code to call non-Rust code that | ||||||||||
calls back into Rust code, and then allow a panic to propagate from Rust to | ||||||||||
Rust across the non-Rust code. | ||||||||||
|
||||||||||
The Rust unwind mechanism is intentionally not specified here. Catching a Rust | ||||||||||
BatmanAoD marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
panic in Rust code compiled with a different Rust toolchain or options is not | ||||||||||
specified. Catching a Rust panic in another language or vice versa is not | ||||||||||
specified. The Rust unwind may or may not run non-Rust destructors as it | ||||||||||
unwinds. Propagating a Rust panic through non-Rust code may require | ||||||||||
BatmanAoD marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
target-specific options for the non-Rust code, or may not be supported at all. | ||||||||||
BatmanAoD marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
BatmanAoD marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
# Drawbacks | ||||||||||
[drawbacks]: #drawbacks | ||||||||||
|
||||||||||
TODO | ||||||||||
BatmanAoD marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
# Rationale and alternatives | ||||||||||
[rationale-and-alternatives]: #rationale-and-alternatives | ||||||||||
|
||||||||||
BatmanAoD marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
TODO | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
- https://github.com/rust-lang/rfcs/pull/2699 | ||||||||||
|
||||||||||
# Prior art | ||||||||||
[prior-art]: #prior-art | ||||||||||
|
||||||||||
TODO | ||||||||||
|
||||||||||
# Unresolved questions | ||||||||||
[unresolved-questions]: #unresolved-questions | ||||||||||
|
||||||||||
TODO | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this already addressed by your point above that "function pointers shall all be considered unwind and no nounwind function pointer shall be introduced"? I think that statement applies to all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ....actually, this should probably be mentioned in the "alternatives" section, now that the primary proposal recommends treating all function pointers as @gnzlbg What do you think of this suggestion? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BatmanAoD If we switch to |
||||||||||
|
||||||||||
# Future possibilities | ||||||||||
[future-possibilities]: #future-possibilities | ||||||||||
|
||||||||||
TODO | ||||||||||
BatmanAoD marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
- `unwind(abort)` | ||||||||||
- non-"C" ABIs |
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.
Note that AFAIK
mozjpeg
does not need this. A 200 LOC diff removes the UB from that library, without a performance impact.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.
I (or whoever fleshes this section out) can mention that. These are just items to mention when this section is written.