Skip to content

ICE occurs after removing Box and do 'cargo check' #61760

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

Closed
shaunxw opened this issue Jun 12, 2019 · 2 comments
Closed

ICE occurs after removing Box and do 'cargo check' #61760

shaunxw opened this issue Jun 12, 2019 · 2 comments
Labels
A-incr-comp Area: Incremental compilation 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.

Comments

@shaunxw
Copy link

shaunxw commented Jun 12, 2019

I tried this code to solve recursive type by Box, did cargo check and everything is fine:

pub enum Enum {
    A(Struct),
}

pub struct Struct {
    // To reproduce the ICE:
    // * Step 1: do `cargo check`
    // * Step 2: change `Box<Enum>` to `Enum`
    // * Step 3: do `cargo check` again
    data: Box<Enum>,
}

fn main() {}

But when I removed Box and did cargo check again, an ICE occurred:

error: internal compiler error: src/librustc/dep_graph/graph.rs:722: try_mark_previous_green() - Forcing the DepNode should have set its color
thread 'rustc' panicked at 'Box', src/librustc_errors/lib.rs:638:9

A demo repo is created to help reproducing this bug.

Meta

The ICE could be reproduced on both stable and nightly.

rustc --version --verbose of stable:

rustc 1.34.1 (fc50f328b 2019-04-24)
binary: rustc
commit-hash: fc50f328b0353b285421b8ff5d4100966387a997
commit-date: 2019-04-24
host: x86_64-apple-darwin
release: 1.34.1
LLVM version: 8.0

rustc --version --verbose of another stable:

rustc 1.35.0 (3c235d560 2019-05-20)
binary: rustc
commit-hash: 3c235d5600393dfe6c36eeed34042efad8d4f26e
commit-date: 2019-05-20
host: x86_64-apple-darwin
release: 1.35.0
LLVM version: 8.0

rustc --version --verbose of nightly:

rustc 1.37.0-nightly (5f3656ce9 2019-06-11)
binary: rustc
commit-hash: 5f3656ce9a2212fad872605b7a4ee103a155e9f3
commit-date: 2019-06-11
host: x86_64-apple-darwin
release: 1.37.0-nightly
LLVM version: 8.0

Backtrace:

> RUST_BACKTRACE=1 cargo check
    Checking box-bug v0.1.0 (/Users/sw/box-bug)
error: internal compiler error: src/librustc/dep_graph/graph.rs:722: try_mark_previous_green() - Forcing the DepNode should have set its color

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:638:9
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   2: rustc::util::common::panic_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: rustc_errors::Handler::bug
   6: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   7: rustc::ty::context::tls::with_opt::{{closure}}
   8: rustc::ty::context::tls::with_context_opt
   9: rustc::ty::context::tls::with_opt
  10: rustc::util::bug::opt_span_bug_fmt
  11: rustc::util::bug::bug_fmt
  12: rustc::dep_graph::graph::DepGraph::try_mark_previous_green
  13: rustc::dep_graph::graph::DepGraph::try_mark_green
  14: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  15: rustc::ty::AdtDef::sized_constraint_for_ty
  16: <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next
  17: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  18: <T as rustc::ty::context::InternIteratorElement<T,R>>::intern_with
  19: rustc::ty::adt_sized_constraint
  20: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::adt_sized_constraint>::compute
  21: rustc::dep_graph::graph::DepGraph::with_task_impl
  22: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query
  23: rustc::ty::query::plumbing::force_from_dep_node
  24: rustc::dep_graph::graph::DepGraph::try_mark_previous_green
  25: rustc::dep_graph::graph::DepGraph::try_mark_previous_green
  26: rustc::dep_graph::graph::DepGraph::try_mark_previous_green
  27: rustc::dep_graph::graph::DepGraph::try_mark_previous_green
  28: rustc::dep_graph::graph::DepGraph::try_mark_green
  29: rustc::dep_graph::graph::DepGraph::try_mark_green_and_read
  30: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor as rustc::hir::itemlikevisit::ParItemLikeVisitor>::visit_item
  31: __rust_maybe_catch_panic
  32: rustc_data_structures::sync::par_for_each_in
  33: __rust_maybe_catch_panic
  34: rustc::hir::Crate::par_visit_all_item_likes
  35: rustc::util::common::time
  36: rustc_typeck::check_crate
  37: rustc_interface::passes::analysis
  38: rustc::ty::query::__query_compute::analysis
  39: rustc::dep_graph::graph::DepGraph::with_task_impl
  40: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  41: rustc::ty::context::tls::enter_global
  42: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  43: rustc_interface::passes::create_global_ctxt::{{closure}}
  44: rustc_interface::interface::run_compiler_in_existing_thread_pool
  45: std::thread::local::LocalKey<T>::with
  46: scoped_tls::ScopedKey<T>::set
  47: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [adt_sized_constraint] processing `Enum`
#1 [adt_sized_constraint] processing `Struct`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
@jonas-schievink jonas-schievink added A-incr-comp Area: Incremental compilation C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 12, 2019
@ackxolotl
Copy link

ackxolotl commented Jun 12, 2019

Same issue as #61323 and #57373. Definitely duplicate.

@jonas-schievink
Copy link
Contributor

Yup, backtrace is the same as in #61323, closing in favor of that (which also has a reproduction)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation 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.
Projects
None yet
Development

No branches or pull requests

3 participants