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 when hitting recursion limit with crate attrs #105700

Closed
jruderman opened this issue Dec 14, 2022 · 1 comment
Closed

ICE when hitting recursion limit with crate attrs #105700

jruderman opened this issue Dec 14, 2022 · 1 comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) 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

@jruderman
Copy link
Contributor

Found with a modified fuzz-rustc

Code

#![recursion_limit="4"]
#![k1]
#![k2]
#![k3]
#![k4]
#![k5]

ICE

thread <unnamed> panicked at 'internal error: entered unreachable code', compiler/rustc_expand/src/base.rs:446

Backtrace
   0:        0x108b08796 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd6dea84f06cc919a
   1:        0x108b6715a - core::fmt::write::h91ecc43dcb5a87d3
   2:        0x108afac5c - std::io::Write::write_fmt::hc922635edee92051
   3:        0x108b0857a - std::sys_common::backtrace::print::h86bd5791976d67a9
   4:        0x108b0b8e3 - std::panicking::default_hook::{{closure}}::h32c4d35e1d887df2
   5:        0x108b0b638 - std::panicking::default_hook::hcd90b2b89f8c0e15
   6:        0x108b0c0a3 - std::panicking::rust_panic_with_hook::h9198f3fe823c744c
   7:        0x108b0be33 - std::panicking::begin_panic_handler::{{closure}}::h935bfbd23a054b53
   8:        0x108b08c38 - std::sys_common::backtrace::__rust_end_short_backtrace::h1a500d61b73a0659
   9:        0x108b0bb3d - _rust_begin_unwind
  10:        0x108b93903 - core::panicking::panic_fmt::he9045b6279698c2c
  11:        0x108b939d7 - core::panicking::panic::h8341ec280685e050
  12:        0x118529672 - <rustc_expand[5335689204dc94a0]::base::DummyResult as rustc_expand[5335689204dc94a0]::base::MacResult>::make_crate
  13:        0x11851a9cb - <rustc_expand[5335689204dc94a0]::expand::AstFragmentKind>::make_from
  14:        0x11850b6b0 - <rustc_expand[5335689204dc94a0]::expand::MacroExpander>::fully_expand_fragment
  15:        0x11850a8ac - <rustc_expand[5335689204dc94a0]::expand::MacroExpander>::expand_crate
  16:        0x118b70d2b - <rustc_session[78db928f84e94300]::session::Session>::time::<core[d953718cd3bcc963]::result::Result<rustc_ast[9bcfca4c6a3003da]::ast::Crate, rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_interface[9fb4355f0ea261b0]::passes::configure_and_expand::{closure#1}>
  17:        0x118b93fab - rustc_interface[9fb4355f0ea261b0]::passes::configure_and_expand
  18:        0x118b1f06e - <rustc_interface[9fb4355f0ea261b0]::queries::Queries>::expansion
  19:        0x1183438b6 - rustc_span[e3bcd7e2de09f7c3]::with_source_map::<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_interface[9fb4355f0ea261b0]::interface::run_compiler<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  20:        0x1183358ee - <scoped_tls[10e5aad72c190240]::ScopedKey<rustc_span[e3bcd7e2de09f7c3]::SessionGlobals>>::set::<rustc_interface[9fb4355f0ea261b0]::interface::run_compiler<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}>::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>
  21:        0x1183043b7 - std[e9f68177e3155681]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[9fb4355f0ea261b0]::util::run_in_thread_pool_with_globals<rustc_interface[9fb4355f0ea261b0]::interface::run_compiler<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}>::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>
  22:        0x1182e6db9 - <<std[e9f68177e3155681]::thread::Builder>::spawn_unchecked_<rustc_interface[9fb4355f0ea261b0]::util::run_in_thread_pool_with_globals<rustc_interface[9fb4355f0ea261b0]::interface::run_compiler<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}>::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>::{closure#1} as core[d953718cd3bcc963]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  23:        0x11a2d93a7 - std::sys::unix::thread::Thread::new::thread_start::h6bf891e61773eb8a
  24:     0x7ff80c3874e1 - __pthread_start

Regression

Regression in nightly-2021-12-02, perhaps from #91313 (@petrochenkov)

Might be related to #99478

Version

rustc 1.68.0-nightly (bdb07a8ec 2022-12-11)
binary: rustc
commit-hash: bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4
commit-date: 2022-12-11
host: x86_64-apple-darwin
release: 1.68.0-nightly
LLVM version: 15.0.6
@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 14, 2022
@Nilstrieb Nilstrieb added the A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) label Dec 14, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 22, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 20, 2023
create dummy placeholder crate to prevent compiler from panicing

This PR is to address the panic found in rust-lang#105700.

There are 2 separate things going on with this panic.
First the code could not generate a dummy response for crate fragment types when it hits the recursion limit.
This PR adds the method to the trait implementation for `DymmyResult` to be able to create a dummy crate node.
This stops the panic from happening.

The second thing that is not addressed (and maybe does not need addressing? 🤷🏻)
is that when you have multiple attributes it ends up treating attributes that follow another as being the result of expanding the former (maybe there is a better way to say that). So you end up hitting the recursion limit. Even though you would think there is no expansion happening here.

If you did not hit the recursion limit the compiler would output that `invalid_attribute` does not exists. But it currently exits before the resolution step when the recursion limit is reached here.
@Alexendoo
Copy link
Member

Fixed by #107721

Alexendoo added a commit to Alexendoo/rust that referenced this issue Feb 22, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 22, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 22, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#107736 ( Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref rust-lang#66893) )
 - rust-lang#108176 (Don't delay `ReError` bug during lexical region resolve)
 - rust-lang#108315 (Lint dead code in closures and generators)
 - rust-lang#108342 (apply query response: actually define opaque types)
 - rust-lang#108344 (Fix test filename for rust-lang#105700)
 - rust-lang#108353 (resolve: Remove `ImportResolver`)

Failed merges:

 - rust-lang#107911 (Add check for invalid #[macro_export] arguments)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) 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

No branches or pull requests

4 participants