-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Prevent aborting guard from aborting the process in a forced unwind #104070
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
47171e0
6223753
37f7d32
ecd04fd
9792636
91afde5
16abe6c
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 |
---|---|---|
|
@@ -274,6 +274,7 @@ pub trait BuilderMethods<'a, 'tcx>: | |
|
||
// These are used by everyone except msvc | ||
fn cleanup_landing_pad(&mut self, pers_fn: Self::Value) -> (Self::Value, Self::Value); | ||
fn filter_landing_pad(&mut self, pers_fn: Self::Value) -> (Self::Value, Self::Value); | ||
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. What is the difference between cleanup and filter? How should a backend implement it? 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. It's purely metadata in LSDA. https://itanium-cxx-abi.github.io/cxx-abi/exceptions.pdf A negative value in action record means filter, a positive value means catch, and zero (or absence of action record) means cleanup. 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 corresponds to section 7.5 "Exception Specification" of that document? 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. I call it The code here doesn't actually specify any exceptions (corresponds to C++ |
||
fn resume(&mut self, exn0: Self::Value, exn1: Self::Value); | ||
|
||
// These are used only by msvc | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# ignore-cross-compile | ||
# only-linux | ||
include ../tools.mk | ||
|
||
all: foo | ||
$(call RUN,foo) | $(CGREP) -v "cannot unwind" | ||
|
||
foo: foo.rs | ||
$(RUSTC) $< |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Tests that forced unwind through POF Rust frames wouldn't trigger our terminating guards. | ||
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. It would be nice to have a Windows version of this test that uses 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. |
||
|
||
#![feature(c_unwind)] | ||
#![no_main] | ||
|
||
extern "C-unwind" { | ||
fn pthread_exit(v: *mut core::ffi::c_void) -> !; | ||
} | ||
|
||
unsafe extern "C" fn call_pthread_exit() { | ||
pthread_exit(core::ptr::null_mut()); | ||
} | ||
|
||
#[no_mangle] | ||
unsafe extern "C-unwind" fn main(_argc: core::ffi::c_int, _argv: *mut *mut core::ffi::c_char) { | ||
call_pthread_exit(); | ||
} |
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.
This seems incorrect?
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.
The proper way to encode this in GCC would be
<<<eh_filter (NULL)>>>
(or even better,<<<eh_must_not_throw (terminate)>>>
, which is something we hoped for for LLVM!). But I don't think there is support in libgccjit yet, @antoyo to confirm?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.
Yeah, I'll take care of this. I'm not done with supporting unwinding yet.
But, please add a
// TODO(antoyo): generate the correct landing pad
.For my personal information, what are
<<<eh_filter (NULL)>>>
and<<<eh_must_not_throw (terminate)>>>
? I've never seen this syntax. Are they C attributes?I don't remember exactly what
filter
is doing, but the proper implementation of this method might be very similar ascleanup_landing_pad
, but without adding toself.cleanup_blocks
.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.
These are part of generic/gimple: https://godbolt.org/z/5adjbahnd