-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: 'C-unwind' ABI #2945
RFC: 'C-unwind' ABI #2945
Conversation
Assuming here that there is a need for only one type of unwinding, which may be wrong seeing @petrochenkov's comment. Would it make sense to have the “handle unwinding” behavior be the |
@Ekleog That was discussed quite a bit among the project group. There is a summary with links to relevant Zulip discussions here. However, I don't believe we ever re-visited this topic after drafting the full specification in the current RFC. From the summary:
This RFC does in fact specify that under |
We discussed the question of how to accommodate the "system" ABI in today's @rust-lang/lang meeting today, and there has also been some discussion on Zulip. Our meeting consensus was to go ahead with adding "unwind" variants to whatever ABIs need them and for which it is appropriate (e.g., |
@rfcbot fcp merge Dear @rust-lang/lang -- I propose to merge this "ffi unwind" RFC. The major change that came out of the conversation on the RFC thread was extending the "C unwind" ABI explicitly to other ABIs, such as "C unwind", "system unwind" and so forth. |
Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
@RalfJung I have addressed your comments. |
I'm not trying to call them as |
C code compiled without the In other words if you turn an |
Thanks @bjorn3 that's good to know that the defining Rust function with the Are there changes coming to the nomicon related to the unwind ABIs and how they interact with
It looks like in order accomplish my goal of replacing a
Does this seem right? I'm not the most familiar with low-level unwinding; thank you for being patient with me and explaining the nuances here. I would find it useful to have these nuances documented in the nomicon. What is the best way to propagate this information over to the rust-lang/bindgen issue tracker to ensure bindgen is able to support this new language feature? |
You may be able to catch_unwind at the boundary with the C code, longjmp over the C code and then resume_unwind once you are back in rust code. I believe setjmp/longjmp can currently only be called from C code though as rust doesn't support the attribute necessary to tell LLVM thag setjmp can return twice. |
@lopopolo Some changes have already landed in the Nomicon repo, but they're not published yet (I'm not sure why). Here's the PR: rust-lang/nomicon#365 It doesn't address the |
I've hacked #![feature(c_unwind)]
unsafe extern "C" fn boom() {}
unsafe extern "C-unwind" fn bang() {}
#[derive(Default, Debug)]
struct X {
inner: Option<unsafe extern "C" fn()>,
}
#[derive(Default, Debug)]
struct Y {
inner: Option<unsafe extern "C-unwind" fn()>,
}
fn main() {
println!("x: {:?}", X::default());
println!("x: {:?}", X { inner: Some(boom) });
println!("y: {:?}", Y::default());
println!("y: {:?}", Y { inner: Some(bang) });
} emits this compilation error on nightly:
|
@BatmanAoD this bit of context is something I did not know before. I think something close to this for your note would be great to add. Maybe with a hint that clang and gcc enable unwinding in C code with the |
My curiosity led me to try this compilation failure with all the standard derivable traits and it looks like none of them are implemented except for #![feature(c_unwind)]
unsafe extern "C" fn boom() {}
unsafe extern "C-unwind" fn bang() {}
#[derive(Default, Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
struct X {
inner: Option<unsafe extern "C" fn()>,
}
#[derive(Default, Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
struct Y {
inner: Option<unsafe extern "C-unwind" fn()>,
}
fn main() {
println!("x: {:?}", X::default());
println!("x: {:?}", X { inner: Some(boom) });
println!("y: {:?}", Y::default());
println!("y: {:?}", Y { inner: Some(bang) });
}
|
For the missing |
The Rust team has put out a call for testing on the `c_unwind` feature and associated `C-unwind` ABI: - rust-lang/rfcs#2945 (comment) I intend to implement mruby's exception unwinding using Rust's panic infrastructure: - #35 This commit changes the Rust toolchain to nightly for this test. Merging this experiment will be blocked on the `C-unwind` ABI making it to stable.
I filed a ticket to add ABI customization for generated bindings to bindgen: The ticket is pretty barebones. I'm not sure if there's any additional context that should be included in the ticket. |
The Rust team has put out a call for testing on the `c_unwind` feature and associated `C-unwind` ABI: - rust-lang/rfcs#2945 (comment) I intend to implement mruby's exception unwinding using Rust's panic infrastructure: - #35 This commit changes the Rust toolchain to nightly for this test. Merging this experiment will be blocked on the `C-unwind` ABI making it to stable.
The Rust team has put out a call for testing on the `c_unwind` feature and associated `C-unwind` ABI: - rust-lang/rfcs#2945 (comment) I intend to implement mruby's exception unwinding using Rust's panic infrastructure: - #35 This commit changes the Rust toolchain to nightly for this test. Merging this experiment will be blocked on the `C-unwind` ABI making it to stable.
The Rust team has put out a call for testing on the `c_unwind` feature and associated `C-unwind` ABI: - rust-lang/rfcs#2945 (comment) I intend to implement mruby's exception unwinding using Rust's panic infrastructure: - #35 This commit changes the Rust toolchain to nightly for this test. Merging this experiment will be blocked on the `C-unwind` ABI making it to stable.
…pls, r=thomcc Add default trait implementations for "c-unwind" ABI function pointers Following up on rust-lang#92964, only add default trait implementations for the `c-unwind` family of function pointers. The previous attempt in rust-lang#92964 added trait implementations for many more ABIs and ran into concerns regarding the increase in size of the libcore rlib. An attempt to abstract away function pointer types behind a unified trait to reduce the duplication of trait impls is being discussed in rust-lang#99531 but this change looks to be blocked on a lang MCP. Following `@RalfJung's` suggestion in rust-lang#99531 (comment), this commit is another cut at rust-lang#92964 but it _only_ adds the impls for `extern "C-unwind" fn` and `unsafe extern "C-unwind" fn`. I am interested in landing this patch to unblock the stabilization of the `c_unwind` feature. RFC: rust-lang/rfcs#2945 Tracking Issue: rust-lang#74990
The Rust team has put out a call for testing on the `c_unwind` feature and associated `C-unwind` ABI: - rust-lang/rfcs#2945 (comment) I intend to implement mruby's exception unwinding using Rust's panic infrastructure: - #35 This commit changes the Rust toolchain to nightly for this test. Merging this experiment will be blocked on the `C-unwind` ABI making it to stable.
The previous conversation on missing traits has been resolved with this PR: |
The Rust team has put out a call for testing on the `c_unwind` feature and associated `C-unwind` ABI: - rust-lang/rfcs#2945 (comment) I intend to implement mruby's exception unwinding using Rust's panic infrastructure: - #35 This commit changes the Rust toolchain to nightly for this test. Merging this experiment will be blocked on the `C-unwind` ABI making it to stable.
The Rust team has put out a call for testing on the `c_unwind` feature and associated `C-unwind` ABI: - rust-lang/rfcs#2945 (comment) I intend to implement mruby's exception unwinding using Rust's panic infrastructure: - #35 This commit changes the Rust toolchain to nightly for this test. Merging this experiment will be blocked on the `C-unwind` ABI making it to stable.
Following up on #92964, only add default trait implementations for the `c-unwind` family of function pointers. The previous attempt in #92964 added trait implementations for many more ABIs and ran into concerns regarding the increase in size of the libcore rlib. An attempt to abstract away function pointer types behind a unified trait to reduce the duplication of trait impls is being discussed in #99531 but this change looks to be blocked on a lang MCP. Following @RalfJung's suggestion in rust-lang/rust#99531 (comment), this commit is another cut at #92964 but it _only_ adds the impls for `extern "C-unwind" fn` and `unsafe extern "C-unwind" fn`. I am interested in landing this patch to unblock the stabilization of the `c_unwind` feature. RFC: rust-lang/rfcs#2945 Tracking Issue: rust-lang/rust#74990
…omcc Add default trait implementations for "c-unwind" ABI function pointers Following up on #92964, only add default trait implementations for the `c-unwind` family of function pointers. The previous attempt in #92964 added trait implementations for many more ABIs and ran into concerns regarding the increase in size of the libcore rlib. An attempt to abstract away function pointer types behind a unified trait to reduce the duplication of trait impls is being discussed in #99531 but this change looks to be blocked on a lang MCP. Following `@RalfJung's` suggestion in rust-lang/rust#99531 (comment), this commit is another cut at #92964 but it _only_ adds the impls for `extern "C-unwind" fn` and `unsafe extern "C-unwind" fn`. I am interested in landing this patch to unblock the stabilization of the `c_unwind` feature. RFC: rust-lang/rfcs#2945 Tracking Issue: rust-lang/rust#74990
This RFC was drafted by the FFI Unwind project group.
Rendered