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 with cfg_eval + stmt_expr_attributes #105228

Closed
jruderman opened this issue Dec 3, 2022 · 0 comments · Fixed by #111054
Closed

ICE with cfg_eval + stmt_expr_attributes #105228

jruderman opened this issue Dec 3, 2022 · 0 comments · Fixed by #111054
Labels
C-bug Category: This is a bug. F-stmt_expr_attributes `#![feature(stmt_expr_attributes)]` 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

@jruderman
Copy link
Contributor

Found by mutating cfg-eval-fail.rs with my fork of fuzz-rustc.

Code

#![feature(cfg_eval)]
#![feature(stmt_expr_attributes)]

#[cfg_eval]
fn main() {
    #[cfg_eval]
    let _ = #[cfg(FALSE)] 0;
    //~^ ERROR removing an expression is not supported in this position
}

Error output

error: removing an expression is not supported in this position

error: expected expression, found ;

thread 'rustc' panicked at 'called Option::unwrap() on a None value', compiler/rustc_builtin_macros/src/cfg_eval.rs:169

Full output including backtrace
error: removing an expression is not supported in this position
 --> asn.rs:7:13
  |
7 |     let _ = #[cfg(FALSE)] 0;
  |             ^^^^^^^^^^^^^

error: expected expression, found `;`
 --> asn.rs:7:28
  |
7 |     let _ = #[cfg(FALSE)] 0;
  |                            ^ expected expression

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_builtin_macros/src/cfg_eval.rs:169:44
stack backtrace:
   0:        0x109a09406 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7aeb894505898234
   1:        0x109a67dca - core::fmt::write::hb0aa72ff55d6ae53
   2:        0x1099fb7ac - std::io::Write::write_fmt::h1945469b78b865f8
   3:        0x109a091ea - std::sys_common::backtrace::print::h85c2438dfd145403
   4:        0x109a0c553 - std::panicking::default_hook::{{closure}}::hdd077715d2b82795
   5:        0x109a0c2a8 - std::panicking::default_hook::he8d3e4e56f8c52ec
   6:        0x1124c502d - rustc_driver[2d5e2c84e80eab0e]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x109a0cd37 - std::panicking::rust_panic_with_hook::h48c87533cff0c7b5
   8:        0x109a0caa3 - std::panicking::begin_panic_handler::{{closure}}::h03e0170622ddc3a5
   9:        0x109a098a8 - std::sys_common::backtrace::__rust_end_short_backtrace::h27a5e4055100ab18
  10:        0x109a0c7ad - _rust_begin_unwind
  11:        0x109a942a3 - core::panicking::panic_fmt::hd88a77e190c81c5c
  12:        0x109a94377 - core::panicking::panic::h5b884905bd1ddb5d
  13:        0x115391fe4 - <<rustc_builtin_macros[f6004bc8d2ed7f37]::cfg_eval::CfgEval>::configure_annotatable::{closure#4} as core[430c2907dc9a6903]::ops::function::FnOnce<(&mut rustc_parse[ccb6115b14db88e3]::parser::Parser,)>>::call_once
  14:        0x115392859 - rustc_builtin_macros[f6004bc8d2ed7f37]::cfg_eval::cfg_eval
  15:        0x115391d61 - <rustc_builtin_macros[f6004bc8d2ed7f37]::cfg_eval::expand as rustc_expand[93ec35c3241e2602]::base::MultiItemModifier>::expand
  16:        0x11662d4a7 - <rustc_expand[93ec35c3241e2602]::expand::MacroExpander>::fully_expand_fragment
  17:        0x11662b723 - <rustc_expand[93ec35c3241e2602]::expand::MacroExpander>::expand_crate
  18:        0x1125c6a9a - <rustc_session[b3c342af35a3ea6a]::session::Session>::time::<core[430c2907dc9a6903]::result::Result<rustc_ast[1df583a4c38224cd]::ast::Crate, rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>, rustc_interface[f59f2966aecfe0a5]::passes::configure_and_expand::{closure#1}>
  19:        0x11256a9c6 - rustc_interface[f59f2966aecfe0a5]::passes::configure_and_expand
  20:        0x1125724f0 - <rustc_interface[f59f2966aecfe0a5]::queries::Queries>::expansion
  21:        0x11249d3d7 - <rustc_interface[f59f2966aecfe0a5]::interface::Compiler>::enter::<rustc_driver[2d5e2c84e80eab0e]::run_compiler::{closure#1}::{closure#2}, core[430c2907dc9a6903]::result::Result<core[430c2907dc9a6903]::option::Option<rustc_interface[f59f2966aecfe0a5]::queries::Linker>, rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>
  22:        0x112437a5d - rustc_span[157adb1f3d5a28e2]::with_source_map::<core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>, rustc_interface[f59f2966aecfe0a5]::interface::run_compiler<core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>, rustc_driver[2d5e2c84e80eab0e]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  23:        0x11249040d - <scoped_tls[86ec2be37ea12d20]::ScopedKey<rustc_span[157adb1f3d5a28e2]::SessionGlobals>>::set::<rustc_interface[f59f2966aecfe0a5]::interface::run_compiler<core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>, rustc_driver[2d5e2c84e80eab0e]::run_compiler::{closure#1}>::{closure#0}, core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>
  24:        0x11245f86a - std[cffeb5472d7fcddb]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f59f2966aecfe0a5]::util::run_in_thread_pool_with_globals<rustc_interface[f59f2966aecfe0a5]::interface::run_compiler<core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>, rustc_driver[2d5e2c84e80eab0e]::run_compiler::{closure#1}>::{closure#0}, core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>
  25:        0x112441795 - <<std[cffeb5472d7fcddb]::thread::Builder>::spawn_unchecked_<rustc_interface[f59f2966aecfe0a5]::util::run_in_thread_pool_with_globals<rustc_interface[f59f2966aecfe0a5]::interface::run_compiler<core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>, rustc_driver[2d5e2c84e80eab0e]::run_compiler::{closure#1}>::{closure#0}, core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[430c2907dc9a6903]::result::Result<(), rustc_errors[17a2ca97c979a6e5]::ErrorGuaranteed>>::{closure#1} as core[430c2907dc9a6903]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  26:        0x109a16007 - std::sys::unix::thread::Thread::new::thread_start::hd82b4d9ec5e0369f
  27:     0x7ff8083354e1 - __pthread_start

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.67.0-nightly (32e613bba 2022-12-02) running on x86_64-apple-darwin

query stack during panic:
end of query stack
error: aborting due to 2 previous errors

Regression

Regression in nightly-2021-04-12

Commits in range
found 9 bors merge commits in the specified range
  commit[0] 2021-04-10UTC: Auto merge of #84016 - Aaron1011:new-preexp-tests, r=petrochenkov
  commit[1] 2021-04-10UTC: Auto merge of #84023 - Aaron1011:derive-invoc-order, r=petrochenkov
  commit[2] 2021-04-11UTC: Auto merge of #84053 - RalfJung:liballoc-miri, r=Manishearth
  commit[3] 2021-04-11UTC: Auto merge of #84071 - nagisa:nixos-patching-fix, r=Mark-Simulacrum
  commit[4] 2021-04-11UTC: Auto merge of #83806 - JohnTitor:issue-51446, r=estebank
  commit[5] 2021-04-11UTC: Auto merge of #82608 - Aaron1011:feature/final-preexp-tts, r=petrochenkov
  commit[6] 2021-04-11UTC: Auto merge of #84063 - LingMan:patch-1, r=nagisa
  commit[7] 2021-04-11UTC: Auto merge of #81469 - tweksteen:android_set_message, r=m-ou-se
  commit[8] 2021-04-11UTC: Auto merge of #83482 - hyd-dev:uwtable, r=nagisa

Version

rustc 1.67.0-nightly (32e613bba 2022-12-02)
binary: rustc
commit-hash: 32e613bbaafee1bcabba48a2257b838f8d1c03d3
commit-date: 2022-12-02
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4

CC @petrochenkov, @Aaron1011, #82679

@jruderman jruderman 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 Dec 3, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 20, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 18, 2023
Do not recover when parsing stmt in cfg-eval.

`parse_stmt` does recovery on its own. When parsing the statement fails, we always get `Ok(None)` instead of an `Err` variant with the diagnostic that we can emit.

To avoid this behaviour, we need to opt-out of recovery for cfg_eval.

Fixes rust-lang#105228
@bors bors closed this as completed in ee26abd May 18, 2023
@dtolnay dtolnay added the F-stmt_expr_attributes `#![feature(stmt_expr_attributes)]` label Dec 22, 2024
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. F-stmt_expr_attributes `#![feature(stmt_expr_attributes)]` 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