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 3 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 { Some(2) } else { None };
oli-obk marked this conversation as resolved.
Show resolved Hide resolved

TyCtxt::try_print_query_stack(&handler, num_frames);

#[cfg(windows)]
unsafe {
Expand Down
5 changes: 4 additions & 1 deletion 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 Down
4 changes: 0 additions & 4 deletions src/test/ui/consts/const-eval/const-eval-query-stack.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,4 @@ LL | let x: &'static i32 = &(1 / 0);
query stack during panic:
#0 [const_eval_raw] const-evaluating `main::promoted[1]`
#1 [const_eval_validated] const-evaluating + checking `main::promoted[1]`
#2 [const_eval_validated] const-evaluating + checking `main::promoted[1]`
oli-obk marked this conversation as resolved.
Show resolved Hide resolved
#3 [normalize_generic_arg_after_erasing_regions] normalizing `main::promoted[1]`
#4 [optimized_mir] optimizing MIR for `main`
#5 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
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
end of query stack
Copy link
Member

Choose a reason for hiding this comment

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

I think this shouldn't be shown when only showing some frames.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok I will fix, thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bjorn3 sorry can you explain that which part I should change?
I think it is correct, because RUST_BACKTRACE is 0 here, so then we will show we're just showing a limited slice of the query stack message

Copy link
Contributor

Choose a reason for hiding this comment

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

What they are suggesting is to remove the end of query stack message. Maybe either print end of query stack or query stack printing limited, use RUST_BACKTRACE=1 to see more depending on whether we're limiting or not? So instead of printing we're just showing a limited... before the stack, we show that after the stack at the cutoff point where it normally says end of query stack

Copy link
Contributor Author

@hosseind75 hosseind75 Sep 23, 2020

Choose a reason for hiding this comment

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

aa ok gotcha, thanks

2 changes: 2 additions & 0 deletions src/test/ui/proc-macro/invalid-punct-ident-1.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
query stack during panic:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please filter this out with more filter instructions in the corresponding .rs file, the same with all the other proc macros.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry I did not understand that what should I do
can you please explain more?

Copy link
Contributor

Choose a reason for hiding this comment

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

Did it not disappear after switching the condition?

Copy link
Contributor

Choose a reason for hiding this comment

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

In case it's still there after the change, what I meant was to add more of the regexes like

// normalize-stderr-test "thread.*panicked.*proc_macro_server.rs.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> ""
// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> ""
// 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" -> ""
in order to filter out these two new lines.
Basically I think you can add

// normalize-stderr-test "query stack during panic:\n" -> "" 
// normalize-stderr-test "end of query stack:\n" -> "" 

and these lines should disappear

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok got it, thanks, I will fix now

end of query stack
error: proc macro panicked
--> $DIR/invalid-punct-ident-1.rs:16:1
|
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/proc-macro/invalid-punct-ident-2.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
query stack during panic:
end of query stack
error: proc macro panicked
--> $DIR/invalid-punct-ident-2.rs:16:1
|
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/proc-macro/invalid-punct-ident-3.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
query stack during panic:
end of query stack
error: proc macro panicked
--> $DIR/invalid-punct-ident-3.rs:16:1
|
Expand Down
10 changes: 7 additions & 3 deletions src/tools/clippy/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,13 @@ 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 {
Some(2)
} else {
None
};

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

fn toolchain_path(home: Option<String>, toolchain: Option<String>) -> Option<PathBuf> {
Expand Down