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

ICE: hygienic-label-1.rs -Zunpretty=everybody_loops : failed to process buffered lint here (dummy = false) #87308

Closed
matthiaskrgr opened this issue Jul 20, 2021 · 3 comments · Fixed by #89500
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

code from ./src/test/ui/hygiene/hygienic-label-1.rs

Code

macro_rules! foo {
    () => { break 'x; } //~ ERROR use of undeclared label `'x`
}

pub fn main() {
    'x: loop { foo!() }
}
 

Meta

rustc --version --verbose:

rustc 1.55.0-nightly (014026d1a 2021-07-19)
binary: rustc
commit-hash: 014026d1a7ca991f82f12efa95ef4dffb29dc8af
commit-date: 2021-07-19
host: x86_64-unknown-linux-gnu
release: 1.55.0-nightly
LLVM version: 12.0.1

Error output

rustc ./src/test/ui/hygiene/hygienic-label-1.rs -Zunpretty=everybody_loops

#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;
macro_rules! foo {
    () => { break 'x ; } //~ ERROR use of undeclared label `'x`
}

pub fn main() { loop { } }
error: internal compiler error: failed to process buffered lint here (dummy = false)
 --> ./src/test/ui/hygiene/hygienic-label-1.rs:2:21
  |
2 |     () => { break 'x; } //~ ERROR use of undeclared label `'x`
  |                     ^
...
6 |     'x: loop { foo!() }
  |                ------ in this macro invocation
  |
  = note: delayed at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/compiler/rustc_lint/src/early.rs:402:18
  = note: this error: internal compiler error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1050:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.55.0-nightly (014026d1a 2021-07-19) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unpretty=everybody_loops

query stack during panic:
end of query stack
Backtrace

#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;
macro_rules! foo {
    () => { break 'x ; } //~ ERROR use of undeclared label `'x`
}

pub fn main() { loop { } }
error: internal compiler error: failed to process buffered lint here (dummy = false)
 --> ./src/test/ui/hygiene/hygienic-label-1.rs:2:21
  |
2 |     () => { break 'x; } //~ ERROR use of undeclared label `'x`
  |                     ^
...
6 |     'x: loop { foo!() }
  |                ------ in this macro invocation
  |
  = note: delayed at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/compiler/rustc_lint/src/early.rs:402:18
  = note: this error: internal compiler error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1050:13
stack backtrace:
   0:     0x7f7ed6258b90 - std::backtrace_rs::backtrace::libunwind::trace::h0f5cd2ee8b0d7274
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f7ed6258b90 - std::backtrace_rs::backtrace::trace_unsynchronized::h06905b5aeda069a1
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7ed6258b90 - std::sys_common::backtrace::_print_fmt::h4fe4c7c875072f30
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f7ed6258b90 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hcc0746f004a9b7ef
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f7ed62c66cc - core::fmt::write::h9a6d9c74526a6c1b
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/core/src/fmt/mod.rs:1115:17
   5:     0x7f7ed624a315 - std::io::Write::write_fmt::h23dab4cc9ce72ee2
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/io/mod.rs:1665:15
   6:     0x7f7ed625c8ab - std::sys_common::backtrace::_print::h173dc702502d65d2
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f7ed625c8ab - std::sys_common::backtrace::print::h61bd27c4742ba817
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f7ed625c8ab - std::panicking::default_hook::{{closure}}::hcaae87f0495ae613
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/panicking.rs:208:50
   9:     0x7f7ed625c381 - std::panicking::default_hook::h0538e728ee080db0
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/panicking.rs:225:9
  10:     0x7f7ed6a35e91 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h9137b7ac1a66352b
  11:     0x7f7ed625d0d9 - std::panicking::rust_panic_with_hook::h3039e236b6ca482c
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/panicking.rs:626:17
  12:     0x7f7ed625cb97 - std::panicking::begin_panic_handler::{{closure}}::h884fbab544ffd91c
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/panicking.rs:519:13
  13:     0x7f7ed625908c - std::sys_common::backtrace::__rust_end_short_backtrace::hdaf2e18ba3d91210
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7f7ed625caf9 - rust_begin_unwind
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/panicking.rs:515:5
  15:     0x7f7ed6225a9b - std::panicking::begin_panic_fmt::h34884936c58ac1e4
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/panicking.rs:457:5
  16:     0x7f7ed8e911f9 - rustc_errors::HandlerInner::flush_delayed::hcfbb4755a27b0762
  17:     0x7f7ed8e8fc5d - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::hc1e614a9f2b01df1
  18:     0x7f7ed854eed6 - core::ptr::drop_in_place<rustc_session::parse::ParseSess>::h953b491fa34a81a2
  19:     0x7f7ed8550c4e - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::h0022ece81d7ea8ce
  20:     0x7f7ed85259ad - core::ptr::drop_in_place<rustc_interface::interface::Compiler>::hd6b908cf96b1ddc0
  21:     0x7f7ed8524f96 - rustc_span::with_source_map::h0260ea075482ae79
  22:     0x7f7ed85371ba - rustc_interface::interface::create_compiler_and_run::he7ef8517199cf024
  23:     0x7f7ed852a099 - scoped_tls::ScopedKey<T>::set::h603cbfb5f6e2dd76
  24:     0x7f7ed8526eda - std::sys_common::backtrace::__rust_begin_short_backtrace::h23393d8936f34bfc
  25:     0x7f7ed8525765 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h513135f67ecd4e6b
  26:     0x7f7ed6269667 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd5b860c6542b008a
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/alloc/src/boxed.rs:1572:9
  27:     0x7f7ed6269667 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc87b98c8a3a585ed
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/alloc/src/boxed.rs:1572:9
  28:     0x7f7ed6269667 - std::sys::unix::thread::Thread::new::thread_start::ha990175c8f3779cc
                               at /rustc/014026d1a7ca991f82f12efa95ef4dffb29dc8af/library/std/src/sys/unix/thread.rs:74:17
  29:     0x7f7ed6175259 - start_thread
  30:     0x7f7ed608a5e3 - __GI___clone
  31:                0x0 - <unknown>

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.55.0-nightly (014026d1a 2021-07-19) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unpretty=everybody_loops

query stack during panic:
end of query stack

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 20, 2021
@matthiaskrgr
Copy link
Member Author

Regression in nightly-2021-07-19

@jonas-schievink
Copy link
Contributor

Looks like #87274? I don't think the fix is in nightly yet

@matthiaskrgr
Copy link
Member Author

Still crashes with 39d8d3a master toolchain

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 12, 2021
Manishearth added a commit to Manishearth/rust that referenced this issue Oct 4, 2021
…nkov

Fix ICE with buffered lint referring to AST node deleted by everybody_loops

Fixes rust-lang#87308. Note the following comment:
https://github.com/rust-lang/rust/blob/08759c691e2e9799a3c6780ffdf910240ebd4a6b/compiler/rustc_lint/src/early.rs#L415-L417

As it turns out, this is not _always_ a bug, because `-Zunpretty=everybody_loops` causes a lot of AST nodes to be deleted, and thus some buffered lints will refer to non-existent node ids. To fix this, my changes simply ignore buffered lints if `-Zunpretty=everybody_loops` is enabled, which, from my understanding, shouldn't be a big issue because it only affects pretty-printing. Of course, a more elegant solution would only ignore buffered lints that actually point at deleted node ids, but I haven't figured out an easy way of achieving this.

For the concrete example in rust-lang#87308, the buffered lint is created [here](https://github.com/rust-lang/rust/blob/08759c691e2e9799a3c6780ffdf910240ebd4a6b/compiler/rustc_expand/src/mbe/macro_rules.rs#L145-L151) with the `lint_node_id` from [here](https://github.com/rust-lang/rust/blob/08759c691e2e9799a3c6780ffdf910240ebd4a6b/compiler/rustc_expand/src/mbe/macro_rules.rs#L319), i.e. it points at the macro _expansion_, which then gets deleted by `ReplaceBodyWithLoop` [here](https://github.com/rust-lang/rust/blob/08759c691e2e9799a3c6780ffdf910240ebd4a6b/compiler/rustc_interface/src/passes.rs#L377).
Manishearth added a commit to Manishearth/rust that referenced this issue Oct 4, 2021
…nkov

Fix ICE with buffered lint referring to AST node deleted by everybody_loops

Fixes rust-lang#87308. Note the following comment:
https://github.com/rust-lang/rust/blob/08759c691e2e9799a3c6780ffdf910240ebd4a6b/compiler/rustc_lint/src/early.rs#L415-L417

As it turns out, this is not _always_ a bug, because `-Zunpretty=everybody_loops` causes a lot of AST nodes to be deleted, and thus some buffered lints will refer to non-existent node ids. To fix this, my changes simply ignore buffered lints if `-Zunpretty=everybody_loops` is enabled, which, from my understanding, shouldn't be a big issue because it only affects pretty-printing. Of course, a more elegant solution would only ignore buffered lints that actually point at deleted node ids, but I haven't figured out an easy way of achieving this.

For the concrete example in rust-lang#87308, the buffered lint is created [here](https://github.com/rust-lang/rust/blob/08759c691e2e9799a3c6780ffdf910240ebd4a6b/compiler/rustc_expand/src/mbe/macro_rules.rs#L145-L151) with the `lint_node_id` from [here](https://github.com/rust-lang/rust/blob/08759c691e2e9799a3c6780ffdf910240ebd4a6b/compiler/rustc_expand/src/mbe/macro_rules.rs#L319), i.e. it points at the macro _expansion_, which then gets deleted by `ReplaceBodyWithLoop` [here](https://github.com/rust-lang/rust/blob/08759c691e2e9799a3c6780ffdf910240ebd4a6b/compiler/rustc_interface/src/passes.rs#L377).
@bors bors closed this as completed in 3d4467d Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants