Skip to content
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

Report non-standard compile flags on ICE #48266

Merged
merged 1 commit into from
Feb 28, 2018

Conversation

pietroalbini
Copy link
Member

@pietroalbini pietroalbini commented Feb 16, 2018

Some ICEs (such as the recent #48248) only happens when a non-standard compiler flag is provided to rustc, but users don't always report the used flags. This can slow down reproducing the issue, so this PR shows all the non-standard compiler flags in the ICE error message.

For example, the output of #48248 with this PR is:

error: internal compiler error: [...]

thread 'rustc' panicked at [...]
note: Run with `RUST_BACKTRACE=1` for a backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: [...]

note: rustc 1.25.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -C link-dead-code

Open questions

  • At the moment, only -C and -Z flags are shown by default, and all the ones provided by cargo in a standard build are ignored: I did this to only show the flags that probably caused the ICE, and to remove some noise from the message. This removed flags like opt-level and debuginfo though, could those be useful for reproducing ICEs?

@rust-highfive
Copy link
Collaborator

r? @michaelwoerister

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 16, 2018
@Mark-Simulacrum
Copy link
Member

I feel like it is generally useful for our ICE reports to contain as much information as possible; for example, I would see it reasonable for us to enable backtrace generation as well as all of the arguments passed to rustc being in the message (some may be useless, but can't really hurt). We can always refine this, removing information seems easier/better than not having it.

@pietroalbini
Copy link
Member Author

@Mark-Simulacrum I'm not sure including all the CLI arguments by default is a wise choice: cargo can emit a lot of them, and the user would just receive a big wall of text, which can be difficult both to analize and to copy/paste correctly. I feel the same about dumping the whole backtrace in the output: for most users is just noise, and copying large amounts of stuff from the terminal can be tricky.

Showing only the relevant stuff (like only the arguments that can change the behavior of rustc) instead can help us reproduce the issue more easily, and if we can't reproduce we can just ask the user "please run that with RUST_BACKTRACE=1".

Another idea that crossed my mind is, we could show the minimal debug message on std{out,err}, and then generate a full report with everything we need (backtraces, full CLI arguments, etc) in /tmp, asking the user to attach it to the bug report. Would this be better?


About what arguments should be displayed, maybe the PR is a bit too restrictive, but some filtering has to be done. For example the arguments for a medium-size project of mine are:

--crate-name fisher --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=c4e0bc4be9695725 -C extra-filename=-c4e0bc4be9695725 --out-dir /home/pietro/r/me/projects/fisher/target/debug/deps -C incremental=/home/pietro/r/me/projects/fisher/target/debug/incremental -L dependency=/home/pietro/r/me/projects/fisher/target/debug/deps --extern serde=/home/pietro/r/me/projects/fisher/target/debug/deps/libserde-52ad7a973c44afe8.rlib --extern url=/home/pietro/r/me/projects/fisher/target/debug/deps/liburl-982ec90bd31517c6.rlib --extern regex=/home/pietro/r/me/projects/fisher/target/debug/deps/libregex-40d45f68045d77f4.rlib --extern nix=/home/pietro/r/me/projects/fisher/target/debug/deps/libnix-50814792add88e20.rlib --extern toml=/home/pietro/r/me/projects/fisher/target/debug/deps/libtoml-14df3774bae804a8.rlib --extern ansi_term=/home/pietro/r/me/projects/fisher/target/debug/deps/libansi_term-1b47dbb0c8fe6208.rlib --extern serde_derive=/home/pietro/r/me/projects/fisher/target/debug/deps/libserde_derive-9e34c4d1f69cd7b2.so --extern rand=/home/pietro/r/me/projects/fisher/target/debug/deps/librand-419c0c549ba418ed.rlib --extern tempdir=/home/pietro/r/me/projects/fisher/target/debug/deps/libtempdir-66df680a4146ee76.rlib --extern serde_json=/home/pietro/r/me/projects/fisher/target/debug/deps/libserde_json-c04b3f33108ce774.rlib --extern lazy_static=/home/pietro/r/me/projects/fisher/target/debug/deps/liblazy_static-2fc6dd1b8699690b.rlib --extern users=/home/pietro/r/me/projects/fisher/target/debug/deps/libusers-7b6784b3555140c5.rlib --extern tiny_http=/home/pietro/r/me/projects/fisher/target/debug/deps/libtiny_http-645d167da63c8a02.rlib --extern error_chain=/home/pietro/r/me/projects/fisher/target/debug/deps/liberror_chain-6ddcf82e6a4f045d.rlib --extern ring=/home/pietro/r/me/projects/fisher/target/debug/deps/libring-7df8d6cfb51f11df.rlib -L native=/home/pietro/r/me/projects/fisher/target/debug/build/backtrace-sys-661b6d1d78dfbd65/out/.libs -L native=/home/pietro/r/me/projects/fisher/target/debug/build/ring-729771622cb6203f/out

Even after removing the --extern and -L, there are still a lot of useless ones:

--crate-name fisher --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=c4e0bc4be9695725 -C extra-filename=-c4e0bc4be9695725 --out-dir /home/pietro/r/me/projects/fisher/target/debug/deps -C incremental=/home/pietro/r/me/projects/fisher/target/debug/incremental

Now, --crate-name, -C metadata=..., -C extra-filename=..., --out-dir and the path in -C incremental are completly useless for debugging what the issue is, so the useful ones are:

--crate-type lib --emit=dep-info,link -C debuginfo=2 -C incremental

Should I change the PR to allow them to show up?

@Mark-Simulacrum
Copy link
Member

The generation of a report in /tmp seems relatively reasonable, but like a separate project (maybe even one worthy of an RFC). Yeah, maybe a whitelist is the best way to go, crate-type, plus anything in -Z, -C, and maybe -W... -L could be potentially useful, but probably too verbose in general.

@pietroalbini pietroalbini added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 16, 2018
@pietroalbini pietroalbini force-pushed the report-compiler-flags-on-ice branch from 054dcbf to d94546c Compare February 17, 2018 23:05
@pietroalbini
Copy link
Member Author

Ok, I relaxed the filtering a bit.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.25.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z treat-err-as-bug -C debuginfo=2 -C incremental --crate-type lib

@pietroalbini pietroalbini added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 17, 2018
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise seems good to me.

if let Ok(string) = arg.into_string() {
args.push(string);
} else {
return None;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I feel like we shouldn't just return None but maybe just use into_string_lossy() here? That seems more reasonable...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, yeah, fixed.

@michaelwoerister
Copy link
Member

Leaving off some arguments while printing others could easily turn out to be misleading. My suggestion is to blacklist -L and --extern and mention in the message that they are omitted.

Another concern is privacy. Including arguments would reveal the directory structure of users, something that not everyone might be comfortable with. Not printing arguments would solve this problem.

@pietroalbini
Copy link
Member Author

pietroalbini commented Feb 19, 2018

Leaving off some arguments while printing others could easily turn out to be misleading. My suggestion is to blacklist -L and --extern and mention in the message that they are omitted.

So you suggest keeping arguments like --crate-name or -C extra-filename=... in the output? My worry is this adds clutter without any practical gain.

Another concern is privacy. Including arguments would reveal the directory structure of users, something that not everyone might be comfortable with. Not printing arguments would solve this problem.

At the moment, I think all the arguments with paths are stripped out. Am I missing any of them?


Edit: I'm a bit busy with exams at the moment, I hope I can finish this PR sometimes later this week.

@michaelwoerister
Copy link
Member

So you suggest keeping arguments like --crate-name or -C extra-filename=... in the output? My worry is this adds clutter without any practical gain.

Yeah, there are case where these make a difference. But you are right, most of the time they won't make a difference. It's fine to leave them off if we list them in the list of a omitted arguments.

At the moment, I think all the arguments with paths are stripped out. Am I missing any of them?

That was more a general comment of mine. If we go with stripping arguments (which I think we should) then I consider the privacy issue solved.

@pietroalbini pietroalbini added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 20, 2018
@pietroalbini pietroalbini force-pushed the report-compiler-flags-on-ice branch from d94546c to 2985a1a Compare February 23, 2018 17:58
@pietroalbini
Copy link
Member Author

pietroalbini commented Feb 23, 2018

@michaelwoerister is this what you mean? Now when the flags provided by cargo by default are hidden the "some of the compiler flags provided by cargo are hidden" note will also appear in the output.

$ RUSTFLAGS="-Z treat-err-as-bug" cargo +stage1 build
   Compiling foo v0.1.0 (file:///home/pietro/r/github/rust-lang/rust/pietro)
[...]

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.25.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z treat-err-as-bug -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `pietro`.

To learn more, run the command again with --verbose.
$ rustc +stage1 src/lib.rs -Z treat-err-as-bug
[...]

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.25.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z treat-err-as-bug

@pietroalbini pietroalbini added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 23, 2018
@michaelwoerister
Copy link
Member

Thanks, @pietroalbini! Yeah, let's try it like that for now. We can always change it if it turns out to be misleading (that is, if people overlook that the list is not exhaustive).

@bors r+

@bors
Copy link
Contributor

bors commented Feb 26, 2018

📌 Commit 2985a1a has been approved by michaelwoerister

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 26, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Feb 27, 2018
…on-ice, r=michaelwoerister

Report non-standard compile flags on ICE

Some ICEs (such as the recent rust-lang#48248) only happens when a non-standard compiler flag is provided to rustc, but users don't always report the used flags. This can slow down reproducing the issue, so this PR shows all the non-standard compiler flags in the ICE error message.

For example, the output of rust-lang#48248 with this PR is:

```
error: internal compiler error: [...]

thread 'rustc' panicked at [...]
note: Run with `RUST_BACKTRACE=1` for a backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: [...]

note: rustc 1.25.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -C link-dead-code
```

### Open questions

* At the moment, only `-C` and `-Z` flags are shown by default, and all the ones provided by cargo in a standard build are ignored: I did this to only show the flags that probably caused the ICE, and to remove some noise from the message. This removed flags like `opt-level` and `debuginfo` though, could those be useful for reproducing ICEs?
kennytm added a commit to kennytm/rust that referenced this pull request Feb 28, 2018
…on-ice, r=michaelwoerister

Report non-standard compile flags on ICE

Some ICEs (such as the recent rust-lang#48248) only happens when a non-standard compiler flag is provided to rustc, but users don't always report the used flags. This can slow down reproducing the issue, so this PR shows all the non-standard compiler flags in the ICE error message.

For example, the output of rust-lang#48248 with this PR is:

```
error: internal compiler error: [...]

thread 'rustc' panicked at [...]
note: Run with `RUST_BACKTRACE=1` for a backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: [...]

note: rustc 1.25.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -C link-dead-code
```

### Open questions

* At the moment, only `-C` and `-Z` flags are shown by default, and all the ones provided by cargo in a standard build are ignored: I did this to only show the flags that probably caused the ICE, and to remove some noise from the message. This removed flags like `opt-level` and `debuginfo` though, could those be useful for reproducing ICEs?
bors added a commit that referenced this pull request Feb 28, 2018
Rollup of 15 pull requests

- Successful merges: #48266, #48321, #48365, #48381, #48450, #48473, #48479, #48484, #48488, #48497, #48541, #48548, #48558, #48560, #48565
- Failed merges:
@bors bors merged commit 2985a1a into rust-lang:master Feb 28, 2018
@pietroalbini pietroalbini deleted the report-compiler-flags-on-ice branch February 28, 2018 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants