-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Update catch_unwind
doc comments for c_unwind
#128321
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 all commits
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 |
---|---|---|
|
@@ -2666,12 +2666,17 @@ extern "rust-intrinsic" { | |
/// | ||
/// `catch_fn` must not unwind. | ||
/// | ||
/// The third argument is a function called if an unwind occurs (both Rust unwinds and foreign | ||
/// unwinds). This function takes the data pointer and a pointer to the target-specific | ||
/// exception object that was caught. For more information, see the compiler's source as well as | ||
/// std's `catch_unwind` implementation. | ||
/// The third argument is a function called if an unwind occurs (both Rust `panic` and foreign | ||
/// unwinds). This function takes the data pointer and a pointer to the target- and | ||
/// runtime-specific exception object that was caught. | ||
/// | ||
/// The stable version of this intrinsic is `std::panic::catch_unwind`. | ||
/// Note that in the case of a foreign unwinding operation, the exception object data may not be | ||
/// safely usable from Rust, and should not be directly exposed via the standard library. To | ||
/// prevent unsafe access, the library implementation may either abort the process or present an | ||
/// opaque error type to the user. | ||
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. This sounds like it is the library implementation that chooses which of the two happen, which I don't think is the case? It would be good to explain somewhere (not as stable docs, but as information for people that want to understand the system) what decides which of these two outcomes occurs. 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. I thought that the library did indeed make that decision from my first look at the code, but on looking again I'm not so sure. The files where the detection, and handling, of "foreign" exceptions occur seems to be in @workingjubilee or @chorman0773 , can either of you confirm that this understanding is correct, and that the standard library, rather than the compiler intrinsic, determines whether 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. I can't speak to how rustc in particular handles things, I can only speak to abi-level handling and guarantees. 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. @nbdd0121 Are you the right person to ask here? 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. Yeah, the library decides 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. Hi, sorry. Yes, that's correct, as mentioned we call
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. Our unwinding code is unfortunately not very localized, and is splashed all over the library folder (workspace, now?). Some of the relevant code is inside library/std and some of it is in library/panic_unwind and some of it is in library/unwind and just... ugh. I think half the reason this situation has not been cleaned up is because it's hard to just find it 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. That sounds like we currently always abort (seeing 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. Yes, we currently always abort, which is why no implementation change accompanies these doc changes. The point of the doc change here is to constrain what we may do in the future, because it is currently officially UB. |
||
/// | ||
/// For more information, see the compiler's source, as well as the documentation for the stable | ||
/// version of this intrinsic, `std::panic::catch_unwind`. | ||
#[rustc_nounwind] | ||
pub fn catch_unwind(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32; | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.