Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

rustc panics given malformed attribute #48387

Closed
darakshan opened this issue Feb 20, 2018 · 1 comment · Fixed by #48990
Closed

rustc panics given malformed attribute #48387

darakshan opened this issue Feb 20, 2018 · 1 comment · Fixed by #48990
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@darakshan
Copy link

A typo in an attribute causes a compiler panic. It is probably connected with the presence of
#![plugin(rocket_codegen)]

I've reduced the offender to a tiny single .rs file and its Cargo.toml.
Rust_bug.zip

@estebank estebank added A-attributes Area: Attributes (`#[…]`, `#![…]`) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Feb 20, 2018
@ExpHP
Copy link
Contributor

ExpHP commented Feb 21, 2018

Further details

The code snippet

It is short enough that it might as well be posted here:

#![feature(plugin, custom_derive, decl_macro)]
#![plugin(rocket_codegen)]

#[get"x"]
fn main() {
	print!("hello world")
}

Note: Commenting out the #![plugin(rocket_codegen)] line resolves the error.

The error:

error: internal compiler error: Error constructed but not emitted

A DiagnosticBuilder is being dropped somewhere. The question is, who created it? Rustc or Rocket? (well, okay, it's obviously gotta be a bug in Rocket, I just haven't been able to prove it yet)

Backtrace (nightly channel)
error: internal compiler error: Error constructed but not emitted

thread 'rustc' panicked at 'explicit panic', librustc_errors/diagnostic_builder.rs:242:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:380
   3: std::panicking::default_hook
             at libstd/panicking.rs:396
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:576
   5: std::panicking::begin_panic
   6: <rustc_errors::diagnostic_builder::DiagnosticBuilder<'a> as core::ops::drop::Drop>::drop
   7: syntax::ext::expand::MacroExpander::expand_invoc
   8: syntax::ext::expand::MacroExpander::expand
   9: syntax::ext::expand::MacroExpander::expand_crate
  10: rustc_driver::driver::phase_2_configure_and_expand_inner::{{closure}}
  11: rustc::util::common::time
  12: rustc_driver::driver::phase_2_configure_and_expand
  13: rustc_driver::driver::compile_input
  14: rustc_driver::run_compiler

(No sign of Rocket in the backtrace, though I'm not sure how much this helps as I don't know if a plugin would normally show up in the stack trace or not; also, there is lots of inlining)

I looked through the Rocket codegen plugin's source trying to brainstorm all sorts of ways that a drop of a DiagnosticBuilder might get hidden in the source code. I did learn something, which is that PResult is very scary!...but I didn't find anything. :V


(I can picture it now; the compiler blows up just moments before printing the actual error message it was supposed to print, because somebody wrote result.unwrap_or_else(|_| cx.span_fatal(span, "something else"))...)

kennytm added a commit to kennytm/rust that referenced this issue Mar 15, 2018
Fix ICE on malformed plugin attributes

See rust-lang#48941 for some discussion.

This bug had several duplicate reports which were never closed as dupes:

Fixes rust-lang#47612
Fixes rust-lang#48387
Fixes rust-lang#48941
Fixes rust-lang#48982
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants