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

Panic in region_scope_tree: assertion failed: prev.is_none() #87877

Closed
danielhenrymantilla opened this issue Aug 9, 2021 · 3 comments · Fixed by #87969
Closed

Panic in region_scope_tree: assertion failed: prev.is_none() #87877

danielhenrymantilla opened this issue Aug 9, 2021 · 3 comments · Fixed by #87969
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) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@danielhenrymantilla
Copy link
Contributor

danielhenrymantilla commented Aug 9, 2021

Context: "regression" caught by future-proofing CI from https://github.com/danielhenrymantilla/stackbox.rs/runs/3278204045?check_suite_focus=true

After working on reducing the code, I've identified the root cause of the ICE.

Code

macro_rules! two_items {() => (
    extern {}
    extern {}
)}

macro_rules! single_item_funneler {( $item:item ) => ( $item )}

fn inside_some_function() {
    single_item_funneler! { two_items! {} }
}
  • For context: this patterns stem from "old" Rust code wanting to support proc-macros emitting item definitions in "statement" position for <1.45.0 Rust: the trick is to use the single_item_funneler to wrap an item-defs-emitting proc-macro call inside a function so that Rust doesn't interpret it as a statement, refusing the then-unstable stmt-emitting proc-macro call (minimal example).

Meta

rustc --version --verbose:

note: rustc 1.56.0-nightly (ad981d58e 2021-08-08) running on x86_64-apple-darwin
  • Bonus: the ICE seems to have been introduced in between today's (👆) and yesterday's nightly.

Error output

thread 'rustc' panicked at 'assertion failed: prev.is_none()', compiler/rustc_middle/src/middle/region.rs:334:13
Backtrace

stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: rustc_middle::middle::region::ScopeTree::record_scope_parent
   4: <rustc_passes::region::RegionResolutionVisitor as rustc_hir::intravisit::Visitor>::visit_stmt
   5: <rustc_passes::region::RegionResolutionVisitor as rustc_hir::intravisit::Visitor>::visit_block
   6: rustc_passes::region::resolve_expr
   7: <rustc_passes::region::RegionResolutionVisitor as rustc_hir::intravisit::Visitor>::visit_body
   8: rustc_passes::region::region_scope_tree
   9: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  10: rustc_data_structures::stack::ensure_sufficient_stack
  11: rustc_query_system::query::plumbing::force_query_with_job
  12: rustc_query_system::query::plumbing::get_query_impl
  13: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::region_scope_tree
  14: rustc_typeck::check::regionck::RegionCtxt::new
  15: rustc_typeck::check::regionck::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::regionck_item
  16: rustc_infer::infer::InferCtxtBuilder::enter
  17: rustc_typeck::check::wfcheck::check_item_well_formed
  18: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  19: rustc_data_structures::stack::ensure_sufficient_stack
  20: rustc_query_system::query::plumbing::force_query_with_job
  21: rustc_query_system::query::plumbing::get_query_impl
  22: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_item_well_formed
  23: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor as rustc_hir::intravisit::Visitor>::visit_item
  24: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  25: rustc_data_structures::sync::par_for_each_in
  26: rustc_session::session::Session::track_errors
  27: rustc_typeck::check_crate
  28: rustc_interface::passes::analysis
  29: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  30: rustc_data_structures::stack::ensure_sufficient_stack
  31: rustc_query_system::query::plumbing::force_query_with_job
  32: rustc_query_system::query::plumbing::get_query_impl
  33: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  34: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  35: rustc_span::with_source_map
  36: rustc_interface::interface::create_compiler_and_run
  37: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.56.0-nightly (ad981d58e 2021-08-08) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [region_scope_tree] computing drop scopes for `main`
#1 [check_item_well_formed] checking that `main` is well-formed
#2 [analysis] running analysis passes on this crate
end of query stack

cc @Aaron1011 I suspect this is up your alley 😉

@danielhenrymantilla danielhenrymantilla 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 Aug 9, 2021
@Nemo157 Nemo157 added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Aug 9, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Aug 9, 2021
@hellow554
Copy link
Contributor

searched nightlies: from nightly-2021-08-01 to nightly-2021-08-10
regressed nightly: nightly-2021-08-07
searched commits: from 2f07ae4 to 5ad7389
regressed commit: 5ad7389

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --end=2021-08-10 --regress=ice --access=github --without-cargo -- check

@apiraino
Copy link
Contributor

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-high +A-macros

@rustbot rustbot added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Aug 12, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 12, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Aug 13, 2021
…enkov

Revert "Rollup merge of rust-lang#87779 - Aaron1011:stmt-ast-id, r=petrochenkov"

Fixes rust-lang#87877

This change interacts badly with `noop_flat_map_stmt`,
which synthesizes multiple statements with the same `NodeId`.

I'm working on a better fix that will still allow us to
remove this special case. For now, let's revert the change
to fix the ICE.

This reverts commit a4262cc, reversing
changes made to 8ee962f.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Aug 13, 2021
…enkov

Revert "Rollup merge of rust-lang#87779 - Aaron1011:stmt-ast-id, r=petrochenkov"

Fixes rust-lang#87877

This change interacts badly with `noop_flat_map_stmt`,
which synthesizes multiple statements with the same `NodeId`.

I'm working on a better fix that will still allow us to
remove this special case. For now, let's revert the change
to fix the ICE.

This reverts commit a4262cc, reversing
changes made to 8ee962f.
@bors bors closed this as completed in cfc3fee Aug 13, 2021
@danielhenrymantilla
Copy link
Contributor Author

Thanks @Aaron1011, nice job 🙂

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) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. 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.

6 participants