-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Don't treat rustc exit on signal as internal error. #6270
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 |
---|---|---|
|
@@ -4373,3 +4373,65 @@ fn target_filters_workspace_not_found() { | |
.with_stderr("[ERROR] no library targets found in packages: a, b") | ||
.run(); | ||
} | ||
|
||
#[cfg(unix)] | ||
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. Despite this being unix only I personally like having tests like this, so I'd definitely keep 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. Doesn't this cause an abnormal exit on all systems? 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, I just didn't want to deal with figuring out the text of the error message on every platform. Windows is something like "3221226505", but is it like that on all versions of windows? (probably?) What about non-tier-1 platforms? I'm already concerned this test might be flaky on weird platforms. 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. For Windows error codes are actually best rendered as hex -- 0xC0000409 instead of 3221226505 -- and I've meant to do that in libstd for some time now... |
||
#[test] | ||
fn signal_display() { | ||
// Cause the compiler to crash with a signal. | ||
let foo = project() | ||
.file( | ||
"Cargo.toml", | ||
r#" | ||
[package] | ||
name = "foo" | ||
version = "0.1.0" | ||
[dependencies] | ||
pm = { path = "pm" } | ||
"#, | ||
) | ||
.file( | ||
"src/lib.rs", | ||
r#" | ||
#[macro_use] | ||
extern crate pm; | ||
|
||
#[derive(Foo)] | ||
pub struct S; | ||
"#, | ||
) | ||
.file( | ||
"pm/Cargo.toml", | ||
r#" | ||
[package] | ||
name = "pm" | ||
version = "0.1.0" | ||
[lib] | ||
proc-macro = true | ||
"#, | ||
) | ||
.file( | ||
"pm/src/lib.rs", | ||
r#" | ||
extern crate proc_macro; | ||
use proc_macro::TokenStream; | ||
|
||
#[proc_macro_derive(Foo)] | ||
pub fn derive(_input: TokenStream) -> TokenStream { | ||
std::process::abort() | ||
} | ||
"#, | ||
) | ||
.build(); | ||
|
||
foo.cargo("build") | ||
.with_stderr("\ | ||
[COMPILING] pm [..] | ||
[COMPILING] foo [..] | ||
[ERROR] Could not compile `foo`. | ||
|
||
Caused by: | ||
process didn't exit successfully: `rustc [..]` (signal: 6, SIGABRT: process abort signal) | ||
") | ||
.with_status(101) | ||
.run(); | ||
} |
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 think rustc only has one erroneous exit code itself, so could we perhaps whitelist just that one exit code to handle cases like Windows to ensure that Windows also prints segfaults by default?
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.
If you think it's safe. It looks like rustdoc uses the same code, I'm just thinking of wrappers using different codes. But maybe that's a good thing?
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.
An alternative is to filter out any exit code less than 128. On Unix I think that's the maximal error code and any portable program won't be using upper codes on Windows. (and on Windows all the abnormal exit codes are far above 128).
Do you think we should perhaps implement that sort of filtering to be a bit more conservative?
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.
Sounds good, also means I don't need to fix the 1.28 failure.