Repository navigation
Closed
Labels
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
May be related to #47713
I tried this code: Compiling the project here, but at this line replacing Gcm with Self
I expected to see this happen: Code compiles or gives error messages
Instead, this happened: Compiler panicked with stack trace below
Meta
rustc --version --verbose:
rustc 1.32.0 (9fda7c223 2019-01-16)
binary: rustc
commit-hash: 9fda7c2237db910e41d6a712e9a2139b352e558b
commit-date: 2019-01-16
host: x86_64-apple-darwin
release: 1.32.0
LLVM version: 8.0
Backtrace:
> RUST_BACKTRACE=1 cargo build
Compiling crypto-pure v0.0.9 (.../crypto-pure)
error: internal compiler error: src/librustc_typeck/check/mod.rs:2406: no type for node 30873: type E (id=30873) in fcx 0x7ffee86dd208
thread 'main' panicked at 'Box<Any>', src/librustc_errors/lib.rs:600:9
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
1: std::sys_common::backtrace::_print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: rustc::util::common::panic_hook
5: std::panicking::rust_panic_with_hook
6: std::panicking::begin_panic
7: rustc_errors::Handler::bug
8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
9: rustc::ty::context::tls::with_opt::{{closure}}
10: rustc::ty::context::tls::with_context_opt
11: rustc::ty::context::tls::with_opt
12: rustc::util::bug::opt_span_bug_fmt
13: rustc::util::bug::bug_fmt
14: rustc_typeck::check::FnCtxt::node_ty
15: <rustc_typeck::check::writeback::WritebackCx<'cx, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_ty
16: rustc::hir::intravisit::walk_qpath
17: <rustc_typeck::check::writeback::WritebackCx<'cx, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
18: rustc::hir::intravisit::walk_expr
19: <rustc_typeck::check::writeback::WritebackCx<'cx, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
20: <rustc_typeck::check::writeback::WritebackCx<'cx, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
21: rustc_typeck::check::writeback::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::resolve_type_vars_in_body
22: rustc::ty::context::tls::with_related_context
23: rustc::infer::InferCtxtBuilder::enter
24: rustc_typeck::check::typeck_tables_of
25: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_tables_of<'tcx>>::compute
26: rustc::ty::context::tls::with_context
27: rustc::dep_graph::graph::DepGraph::with_task_impl
28: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
29: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
32: rustc::session::Session::track_errors
33: rustc_typeck::check::typeck_item_bodies
34: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_item_bodies<'tcx>>::compute
35: rustc::ty::context::tls::with_context
36: rustc::dep_graph::graph::DepGraph::with_task_impl
37: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
38: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
40: rustc::util::common::time
41: rustc_typeck::check_crate
42: rustc::ty::context::tls::enter_context
43: <std::thread::local::LocalKey<T>>::with
44: rustc::ty::context::TyCtxt::create_and_enter
45: rustc_driver::driver::compile_input
46: rustc_driver::run_compiler_with_pool
47: <scoped_tls::ScopedKey<T>>::set
48: rustc_driver::run_compiler
49: rustc_driver::monitor::{{closure}}
50: __rust_maybe_catch_panic
51: rustc_driver::run
52: rustc_driver::main
53: std::rt::lang_start::{{closure}}
54: std::panicking::try::do_call
55: __rust_maybe_catch_panic
56: std::rt::lang_start_internal
57: main
query stack during panic:
#0 [typeck_tables_of] processing `<gcm::Gcm<E> as gcm::AeadCipher>::new`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: aborting due to previous error
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.32.0 (9fda7c223 2019-01-16) running on x86_64-apple-darwin
note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `crypto-pure`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Activity
memoryruins commentedon Jan 27, 2019
Panics on
rustc 1.33.0-nightly (20c2cba61 2019-01-26)as well.Somewhat minimized:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=1f80547774e123df5705622a026e5104
memoryruins commentedon Jan 27, 2019
ICEs occur on 1.31 and 1.30 as well. Previously, 1.29 produced the error.
memoryruins commentedon Jan 27, 2019
cargo bisect rustc helped narrow the regression to
nightly-2018-09-15edit: #53751 seems possible. there has been a bit of changes to the code since, including fixes to other ICEs dealing with
Self(#56850).hellow554 commentedon Feb 12, 2019
Minified:
ICE does not happen with
Self(e)in the crash functionaoikonomopoulos commentedon Mar 8, 2019
Tried to figure out the root cause by creating a similar, but passing, test case (using
Gcminstead ofSelf). Looking at the differences of the debug logs, I ended up ininstantiate_value_path. AFAICT the issue seems to be thatpath_segsstarting from theDefofSelfCtordef_idof the replacementStructCtorpath_segsin the callback passed tocreate_substs_for_generic_argswhich then tries to look up the generic arguments starting from the newdef_idSpecifically, what I'm seeing is that, when starting out from
SelfCtor,def_id_for_path_segmentstreats it just likeStructCtor. I.e. it queries its generics (generics_of) and then uses thedef_idof the parent, if available.SelfCtordoesn't have a parent[0], hencedef_id_for_path_segmentspushes thedef_idof theImplin the returnedVec.The
Vecgets assigned topath_segsin the body ofinstantiate_value_path, which then (viaimpl_self_ty) resolves theSelfCtorto theStructCtorof theimplthatSelfrefers to and assigns theDefIdof theStructCtortodef_id.Later, it calls into
create_substs_for_generic_args, giving it a callback that will look up the generic args byDefId. Thedef_idargument that it passes refers to theStructCtor, so thestackthat is built is the same regardless of whetherSelfis used or not.The first element popped off the stack is
DefId(0/0:3 ~ <cratename>[317d]::GcmX[0]), which gets passed to the callback provided byinstantiate_value_path. The callback tries to look up thisDefIdand fails (whereas it would succeed if we were not usingSelf).AFAIU, this is because we calculated
path_segsstarting from theImpl, but we're looking up theargs_for_def_idusing the parents of theStructCtor.I tried to move the part that rewrites the
DefforSelfearlier in the function (which also required moving the early exit forLocal/Upvarto the beginning of the function) and this seems to fix this issue (and all tests still pass). However, as commit 2157958 that introduced theSelfCtorrewriting explicitly placed it right before the call tocreate_substs_for_generic_args, I'm unsure as to whether this is the most appropriate fix (or indeed a correct fix).[0]
generics_ofworks withNodes, there's noSelfCtorat that point.Rollup merge of rust-lang#59025 - aoikonomopoulos:issue-57924, r=varkor
Rollup merge of rust-lang#59025 - aoikonomopoulos:issue-57924, r=varkor
Rollup merge of rust-lang#59025 - aoikonomopoulos:issue-57924, r=varkor
Rollup merge of rust-lang#59025 - aoikonomopoulos:issue-57924, r=varkor
Rollup merge of rust-lang#59025 - aoikonomopoulos:issue-57924, r=varkor