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

ICEs should print the top of the query stack #76920

Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5fd6301
ICEs should print the top of the query stack
hosseind75 Sep 19, 2020
132c9ef
run full query stack print just when RUST_BACKTRACE is set
hosseind75 Sep 19, 2020
767e84a
change approach and run ui tests
hosseind75 Sep 19, 2020
339181a
show a message when we are showing limited slice of query stack
hosseind75 Sep 19, 2020
51c32f4
fix invalid-punct-ident-1 test
hosseind75 Sep 19, 2020
d8af4b3
add filter regexes to load-panic-backtraces test
hosseind75 Sep 20, 2020
cdd3126
fix show we're just showing... message instead of the end of query st…
hosseind75 Sep 23, 2020
e29e150
fix clippy custom_ice_message test
hosseind75 Sep 25, 2020
3621afe
add new line
hosseind75 Sep 28, 2020
4e88307
Merge pull request #1 from rust-lang/master
hosseind75 Sep 28, 2020
58cf7c4
merge master into
hosseind75 Sep 28, 2020
8528f40
update master
hosseind75 Sep 29, 2020
1582733
update branch with master
hosseind75 Sep 29, 2020
8983d5b
ICEs should print the top of the query stack
hosseind75 Sep 19, 2020
a1ef12b
run full query stack print just when RUST_BACKTRACE is set
hosseind75 Sep 19, 2020
3be44f9
fix invalid-punct-ident-1 test
hosseind75 Sep 19, 2020
56d6be3
add filter regexes to load-panic-backtraces test
hosseind75 Sep 20, 2020
e837539
fix show we're just showing... message instead of the end of query st…
hosseind75 Sep 23, 2020
51d2e7e
fix clippy custom_ice_message test
hosseind75 Sep 25, 2020
8bfeaef
add new line
hosseind75 Sep 28, 2020
d61d859
rebase with master
hosseind75 Sep 29, 2020
f4b7a5e
rebase with master
hosseind75 Sep 29, 2020
bf73a64
fix rebase messed up files
hosseind75 Sep 29, 2020
665bd46
remove new line
hosseind75 Sep 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1205,9 +1205,9 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
// If backtraces are enabled, also print the query stack
let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false);

if backtrace {
TyCtxt::try_print_query_stack(&handler);
}
let num_frames = if backtrace { None } else { Some(2) };

TyCtxt::try_print_query_stack(&handler, num_frames);

#[cfg(windows)]
unsafe {
Expand Down
11 changes: 9 additions & 2 deletions compiler/rustc_middle/src/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<'tcx> TyCtxt<'tcx> {
})
}

pub fn try_print_query_stack(handler: &Handler) {
pub fn try_print_query_stack(handler: &Handler, num_frames: Option<usize>) {
eprintln!("query stack during panic:");

// Be careful reyling on global state here: this code is called from
Expand All @@ -138,6 +138,9 @@ impl<'tcx> TyCtxt<'tcx> {
let mut i = 0;

while let Some(query) = current_query {
if num_frames == Some(i) {
break;
}
let query_info =
if let Some(info) = query_map.as_ref().and_then(|map| map.get(&query)) {
info
Expand All @@ -163,7 +166,11 @@ impl<'tcx> TyCtxt<'tcx> {
}
});

eprintln!("end of query stack");
if num_frames != None {
eprintln!("we're just showing a limited slice of the query stack");
} else {
eprintln!("end of query stack");
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/pattern/const-pat-ice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ note: rustc VERSION running on TARGET

note: compiler flags: FLAGS

query stack during panic:
oli-obk marked this conversation as resolved.
Show resolved Hide resolved
#0 [check_match] match-checking `main`
#1 [analysis] running analysis passes on this crate
we're just showing a limited slice of the query stack
3 changes: 3 additions & 0 deletions src/test/ui/proc-macro/invalid-punct-ident-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
// normalize-stderr-test "note: compiler flags.*\n\n" -> ""
// normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
// normalize-stderr-test "query stack during panic:\n" -> ""
// normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> ""
// normalize-stderr-test "end of query stack\n" -> ""

#[macro_use]
extern crate invalid_punct_ident;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/proc-macro/invalid-punct-ident-1.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: proc macro panicked
--> $DIR/invalid-punct-ident-1.rs:16:1
--> $DIR/invalid-punct-ident-1.rs:19:1
|
LL | invalid_punct!();
| ^^^^^^^^^^^^^^^^^
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/proc-macro/invalid-punct-ident-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
// normalize-stderr-test "note: compiler flags.*\n\n" -> ""
// normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
// normalize-stderr-test "query stack during panic:\n" -> ""
// normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> ""
// normalize-stderr-test "end of query stack\n" -> ""

#[macro_use]
extern crate invalid_punct_ident;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/proc-macro/invalid-punct-ident-2.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: proc macro panicked
--> $DIR/invalid-punct-ident-2.rs:16:1
--> $DIR/invalid-punct-ident-2.rs:19:1
|
LL | invalid_ident!();
| ^^^^^^^^^^^^^^^^^
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/proc-macro/invalid-punct-ident-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
// normalize-stderr-test "note: compiler flags.*\n\n" -> ""
// normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
// normalize-stderr-test "query stack during panic:\n" -> ""
// normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> ""
// normalize-stderr-test "end of query stack\n" -> ""

#[macro_use]
extern crate invalid_punct_ident;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/proc-macro/invalid-punct-ident-3.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: proc macro panicked
--> $DIR/invalid-punct-ident-3.rs:16:1
--> $DIR/invalid-punct-ident-3.rs:19:1
|
LL | invalid_raw_ident!();
| ^^^^^^^^^^^^^^^^^^^^^
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/proc-macro/load-panic-backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
// normalize-stderr-test "note: compiler flags.*\n\n" -> ""
// normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
// normalize-stderr-test "query stack during panic:\n" -> ""
// normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> ""
// normalize-stderr-test "end of query stack\n" -> ""

#[macro_use]
extern crate test_macros;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/proc-macro/load-panic-backtrace.stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
at 'panic-derive', $DIR/auxiliary/test-macros.rs:43:5
error: proc-macro derive panicked
--> $DIR/load-panic-backtrace.rs:17:10
--> $DIR/load-panic-backtrace.rs:20:10
|
LL | #[derive(Panic)]
| ^^^^^
Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
// If backtraces are enabled, also print the query stack
let backtrace = env::var_os("RUST_BACKTRACE").map_or(false, |x| &x != "0");

if backtrace {
TyCtxt::try_print_query_stack(&handler);
}
let num_frames = if backtrace { None } else { Some(2) };

TyCtxt::try_print_query_stack(&handler, num_frames);
}

fn toolchain_path(home: Option<String>, toolchain: Option<String>) -> Option<PathBuf> {
Expand Down
2 changes: 2 additions & 0 deletions src/tools/clippy/tests/ui/custom_ice_message.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy

note: Clippy version: foo

query stack during panic:
we're just showing a limited slice of the query stack
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like you are missing a newline at the end here