Skip to content

Rustc panic when building bobbin-sdk #58767

Description

@N5FPP

While attempting to build the current bobbin-sdk under Ubuntu 18.04 using rust 1.34.0-nightly (02c4c28 2019-02-26) I get a panic in rustc.

$ RUST_BACKTRACE=1 make
...
cargo build
   Compiling bobbin-hz v0.1.0 (/home/pascal/Workspaces/Rust/STM32/bobbin-sdk/lib/bobbin-hz)
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:345:21
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:482
   6: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:385
   7: rust_begin_unwind
             at src/libstd/panicking.rs:312
   8: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   9: core::panicking::panic
             at src/libcore/panicking.rs:49
  10: rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::ref_to_mplace
  11: rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::deref_operand
  12: rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::place_projection
  13: rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::eval_place
  14: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::run
  15: rustc_mir::const_eval::eval_body_using_ecx
  16: rustc_mir::const_eval::const_eval_raw_provider
  17: rustc::ty::query::__query_compute::const_eval_raw
  18: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval_raw<'tcx>>::compute
  19: rustc::dep_graph::graph::DepGraph::with_task_impl
  20: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  21: rustc_mir::const_eval::const_eval_provider
  22: rustc::ty::query::__query_compute::const_eval
  23: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval<'tcx>>::compute
  24: rustc::dep_graph::graph::DepGraph::with_task_impl
  25: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  26: rustc_mir::const_eval::const_eval_provider
  27: rustc::ty::query::__query_compute::const_eval
  28: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval<'tcx>>::compute
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  31: rustc_mir::monomorphize::collector::collect_items_rec
  32: rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}
  33: rustc::util::common::time
  34: rustc_mir::monomorphize::collector::collect_crate_mono_items
  35: rustc::util::common::time
  36: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
  37: rustc::ty::query::__query_compute::collect_and_partition_mono_items
  38: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::collect_and_partition_mono_items<'tcx>>::compute
  39: rustc::dep_graph::graph::DepGraph::with_task_impl
  40: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  41: rustc_codegen_ssa::back::symbol_export::exported_symbols_provider_local
  42: rustc::ty::query::__query_compute::exported_symbols
  43: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::exported_symbols<'tcx>>::compute
  44: rustc::dep_graph::graph::DepGraph::with_task_impl
  45: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  46: rustc_metadata::encoder::encode_metadata
  47: rustc_metadata::cstore_impl::<impl rustc::middle::cstore::CrateStore for rustc_metadata::cstore::CStore>::encode_metadata
  48: rustc::ty::context::TyCtxt::encode_metadata
  49: rustc_codegen_llvm::base::write_metadata
  50: rustc::util::common::time
  51: rustc_codegen_ssa::base::codegen_crate
  52: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  53: rustc::util::common::time
  54: rustc_driver::driver::phase_4_codegen
  55: rustc_driver::driver::compile_input::{{closure}}
  56: <std::thread::local::LocalKey<T>>::with
  57: rustc::ty::context::TyCtxt::create_and_enter
  58: rustc_driver::driver::compile_input
  59: rustc_driver::run_compiler_with_pool
  60: <scoped_tls::ScopedKey<T>>::set
  61: rustc_driver::run_compiler
  62: syntax::with_globals
  63: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:87
  64: <F as alloc::boxed::FnBox<A>>::call_box
  65: std::sys::unix::thread::Thread::new::thread_start
             at /rustc/02c4c28920ddfdb43e68a363b7fe59ac4c92399c/src/liballoc/boxed.rs:759
             at src/libstd/sys_common/thread.rs:14
             at src/libstd/sys/unix/thread.rs:81
  66: start_thread
  67: __clone
query stack during panic:
#0 [const_eval_raw] const-evaluating `Hz::as_u32`
#1 [const_eval] const-evaluating + checking `Hz::as_u32`
#2 [const_eval] const-evaluating + checking `Hz::as_u32`
#3 [collect_and_partition_mono_items] collect_and_partition_mono_items
#4 [exported_symbols] exported_symbols
end of query stack

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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.34.0-nightly (02c4c2892 2019-02-26) running on x86_64-unknown-linux-gnu

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 `bobbin-hz`.

To learn more, run the command again with --verbose.

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)
    on Feb 27, 2019
  2. Centril commented on Feb 27, 2019

    @Centril
    Contributor
  3. self-assigned this
    on Feb 27, 2019
  4. oli-obk commented on Feb 27, 2019

    @oli-obk
    Contributor

    Minimal repro:

    pub struct Hz;
    
    impl Hz {
        pub const fn num(&self) -> u32 {
            42
        }
        pub const fn normalized(&self) -> Hz {
            Hz
        }
    
        pub const fn as_u32(&self) -> u32 {
            self.normalized().num()
        }
    }

    you need both the self, a method call .normalized, and a method call on the result of that in order to trigger promotion. It seems like self.normalized() is promoted to make a &Hz for the call to num

  5. oli-obk commented on Feb 27, 2019

    @oli-obk
    Contributor

    Ok, so promotion is indeed screwing up. The MIR is promoting the self argument.

    4c4
    < // disambiguator = before
    ---
    > // disambiguator = after
    14,24c14
    <         StorageLive(_3);                 // bb0[1]: scope 0 at src/lib.rs:12:9: 12:26
    <         StorageLive(_4);                 // bb0[2]: scope 0 at src/lib.rs:12:9: 12:13
    <         _4 = &(*_1);                     // bb0[3]: scope 0 at src/lib.rs:12:9: 12:13
    <         _3 = const Hz::normalized(move _4) -> [return: bb2, unwind: bb1]; // bb0[4]: scope 0 at src/lib.rs:12:9: 12:26
    <                                          // ty::Const
    <                                          // + ty: for<'r> fn(&'r Hz) -> Hz {Hz::normalized}
    <                                          // + val: Scalar(Bits { size: 0, bits: 0 })
    <                                          // mir::Constant
    <                                          // + span: src/lib.rs:12:14: 12:24
    <                                          // + ty: for<'r> fn(&'r Hz) -> Hz {Hz::normalized}
    <                                          // + literal: Evaluated(Const { ty: for<'r> fn(&'r Hz) -> Hz {Hz::normalized}, val: Scalar(Bits { size: 0, bits: 0 }) })
    ---
    >         goto -> bb2;                     // bb0[1]: scope 0 at src/lib.rs:12:9: 12:26
    32,34c22,23
    <         _2 = &_3;                        // bb2[0]: scope 0 at src/lib.rs:12:9: 12:26
    <         StorageDead(_4);                 // bb2[1]: scope 0 at src/lib.rs:12:25: 12:26
    <         _0 = const Hz::num(move _2) -> [return: bb3, unwind: bb1]; // bb2[2]: scope 0 at src/lib.rs:12:9: 12:32
    ---
    >         _2 = &(promoted[0]: Hz);         // bb2[0]: scope 0 at src/lib.rs:12:9: 12:26
    >         _0 = const Hz::num(move _2) -> [return: bb3, unwind: bb1]; // bb2[1]: scope 0 at src/lib.rs:12:9: 12:32
    46,47c35
    <         StorageDead(_3);                 // bb3[1]: scope 0 at src/lib.rs:13:5: 13:6
    <         return;                          // bb3[2]: scope 0 at src/lib.rs:13:6: 13:6
    ---
    >         return;                          // bb3[1]: scope 0 at src/lib.rs:13:6: 13:6
    
  6. pnkfelix commented on Feb 28, 2019

    @pnkfelix
    Contributor

    triage: P-high. Looks under control.

  7. N5FPP commented on Mar 9, 2019

    @N5FPP
    Author

    Just to confirm, this has not made it out to the nightly, correct? As of today I am still seeing the same error when attempting to build bobbin-hz as part of bobbin-sdk.

  8. oli-obk commented on Mar 10, 2019

    @oli-obk
    Contributor

    No, #58784 is still open, I'll bump its priority

  9. added 2 commits that reference this issue on Mar 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions