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

Compiler crash during monomorphization #53468

Closed
hrvolapeter opened this issue Aug 18, 2018 · 6 comments
Closed

Compiler crash during monomorphization #53468

hrvolapeter opened this issue Aug 18, 2018 · 6 comments
Assignees
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html 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

@hrvolapeter
Copy link
Member

hrvolapeter commented Aug 18, 2018

Compiler crashes with: Cannot create local mono-item for DefId(134/0:1418 ~ script[8 738]::dom[0]::bindings[0]::interface[0]::invalid_constructor[0])

This minimal example ICEs. This same bug also occurs in https://github.com/retep007/servo-1/tree/ice

Meta

Version: rustc 1.29.0-nightly (1ecf6929d 2018-07-16) running on x86_64-apple-darwin
Compiler flags: -C debuginfo=2 --crate-type lib

Backtrace:

Expandable

Thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554: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::session::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::session::opt_span_bug_fmt
  13: rustc::session::bug_fmt
  14: rustc_mir::monomorphize::collector::should_monomorphize_locally
  15: rustc_mir::monomorphize::collector::collect_miri
  16: rustc_mir::monomorphize::collector::collect_miri
  17: rustc_mir::monomorphize::collector::collect_const
  18: rustc_mir::monomorphize::collector::collect_items_rec
  19: rustc_mir::monomorphize::collector::collect_items_rec
  20: rustc_mir::monomorphize::collector::collect_items_rec
  21: rustc_mir::monomorphize::collector::collect_items_rec
  22: rustc_mir::monomorphize::collector::collect_items_rec
  23: rustc_mir::monomorphize::collector::collect_items_rec
  24: rustc_mir::monomorphize::collector::collect_items_rec
  25: rustc_mir::monomorphize::collector::collect_items_rec
  26: rustc_mir::monomorphize::collector::collect_items_rec
  27: rustc_mir::monomorphize::collector::collect_items_rec
  28: rustc_mir::monomorphize::collector::collect_items_rec
  29: rustc_mir::monomorphize::collector::collect_items_rec
  30: rustc_mir::monomorphize::collector::collect_items_rec
  31: rustc_mir::monomorphize::collector::collect_items_rec
  32: rustc_mir::monomorphize::collector::collect_items_rec
  33: rustc_mir::monomorphize::collector::collect_items_rec
  34: rustc_mir::monomorphize::collector::collect_items_rec
  35: rustc_mir::monomorphize::collector::collect_items_rec
  36: rustc_mir::monomorphize::collector::collect_items_rec
  37: rustc_mir::monomorphize::collector::collect_items_rec
  38: rustc_mir::monomorphize::collector::collect_items_rec
  39: rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}
  40: rustc::util::common::time
41: rustc_mir::monomorphize::collector::collect_crate_mono_items
  42: rustc::util::common::time
  43: rustc_codegen_llvm::base::collect_and_partition_mono_items
  44: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::collect_and_partition_mono_it
ems<'tcx>>::compute
  45: rustc::dep_graph::graph::DepGraph::with_task_impl
  46: rustc::ty::context::tls::with_related_context
  47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  48: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  49: rustc_codegen_llvm::back::symbol_export::exported_symbols_provider_local
  50: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::exported_symbols<'tcx>>::comp
ute
  51: rustc::dep_graph::graph::DepGraph::with_task_impl
  52: rustc::ty::context::tls::with_related_context
  53: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  54: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  55: rustc_metadata::encoder::encode_metadata
  56: rustc_metadata::cstore_impl::<impl rustc::middle::cstore::CrateStore for rustc_metadata::cstore::CStore>::encode_metadata
  57: rustc::ty::context::TyCtxt::encode_metadata
  58: rustc_codegen_llvm::base::write_metadata
  59: rustc::util::common::time
  60: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  61: rustc::util::common::time
  62: rustc_driver::driver::phase_4_codegen
  63: rustc_driver::driver::compile_input::{{closure}}
  64: rustc::ty::context::tls::enter_context
  65: <std::thread::local::LocalKey<T>>::with
  66: rustc::ty::context::TyCtxt::create_and_enter
  67: rustc_driver::driver::compile_input
  68: rustc_driver::run_compiler_with_pool
  69: <scoped_tls::ScopedKey<T>>::set
  70: <scoped_tls::ScopedKey<T>>::set
  71: syntax::with_globals
  72: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  73: __rust_maybe_catch_panic
  74: rustc_driver::run
  75: rustc_driver::main
  76: std::rt::lang_start::{{closure}}
  77: std::panicking::try::do_call
  78: __rust_maybe_catch_panic
  79: std::rt::lang_start_internal
  80: main

EDIT: added link to minimal example
@hrvolapeter hrvolapeter added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Aug 18, 2018
@hrvolapeter hrvolapeter changed the title Compiler crashes during monomorphization Nightly compiler crashes during monomorphization Aug 18, 2018
@hrvolapeter hrvolapeter changed the title Nightly compiler crashes during monomorphization Compiler crash during monomorphization Aug 18, 2018
@hrvolapeter
Copy link
Member Author

Still occurs in rustc 1.30.0-nightly

@hrvolapeter hrvolapeter added the A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html label Aug 28, 2018
@hrvolapeter hrvolapeter added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Sep 9, 2018
@hrvolapeter
Copy link
Member Author

I managed to limit the scope of this ICE a bit. Error seems to be related to const fn at line after replacing const with static variable compilation ICEs at next const function

@hrvolapeter
Copy link
Member Author

I've managed to minimize code even further.
The problem is const fn as mentioned earlier. You can use this repo to reproduce. Just compile b. This bug still occurs in rustc 1.30.0-nightly (cb6d2dfa8 2018-09-16)

@bobbobbio
Copy link

Perhaps unrelated, but this open issue has a similar failure mode and still fails in 1.30.

@hrvolapeter
Copy link
Member Author

Yes, the reported error is the same. However, this is quite general error and my problem was caused by using experimental feature const fn. My bug is reproducible in this minimal example and as far as I know it is not fixed yet

@oli-obk oli-obk added the A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. label Nov 2, 2018
@oli-obk oli-obk self-assigned this Nov 2, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Nov 19, 2018

Duplicate of #53451

@oli-obk oli-obk marked this as a duplicate of #53451 Nov 19, 2018
@oli-obk oli-obk closed this as completed Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html 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