I get the following internal compiler error with rustc nightly:
thread 'rustc' panicked at 'Tried to access field 0 of union with 0 fields', src/librustc_target/abi/mod.rs:742:17
note: run with `RUST_BACKTRACE=1` environment variable to display a 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/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.40.0-nightly (e413dc36a 2019-10-14) 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
To reproduce, just checkout the repo at the following commit: https://github.com/paritytech/polkadot/commit/317411718ce6450923aa2b8ef6ebae4eba9408e5
Run: BUILD_DUMMY_WASM_BINARY=1 cargo build -p polkadot-service
To reproduce, just checkout the repo at the following commit: paritytech/polkadot@3174117
Can you please provide a minimized example that would fit in the playground without any dependencies? We would also appreciate a backtrace.
Sorry for forgetting the backtrace, here we go:
thread 'rustc' panicked at 'Tried to access field 0 of union with 0 fields', src/librustc_target/abi/mod.rs:742:17
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:77
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:61
4: core::fmt::write
at src/libcore/fmt/mod.rs:1028
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1412
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:65
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:50
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:189
9: std::panicking::default_hook
at src/libstd/panicking.rs:206
10: rustc_driver::report_ice
11: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:473
12: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:376
13: std::panicking::begin_panic_fmt
at src/libstd/panicking.rs:331
14: rustc_target::abi::FieldPlacement::offset
15: rustc_codegen_ssa::mir::place::PlaceRef<V>::project_field
16: rustc_codegen_ssa::mir::place::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_place
17: rustc_codegen_ssa::mir::codegen_mir
18: rustc_codegen_ssa::base::codegen_instance
19: <rustc::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define
20: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
21: rustc::dep_graph::graph::DepGraph::with_task
22: rustc_codegen_llvm::base::compile_codegen_unit
23: rustc_codegen_ssa::base::codegen_crate
24: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
25: rustc_interface::passes::start_codegen::{{closure}}
26: rustc::util::common::time
27: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
28: rustc_interface::passes::create_global_ctxt::{{closure}}
29: rustc_interface::queries::Query<T>::compute
30: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::ongoing_codegen
31: rustc_interface::interface::run_compiler_in_existing_thread_pool
32: std::thread::local::LocalKey<T>::with
33: scoped_tls::ScopedKey<T>::set
34: syntax::with_globals
Regarding a minimized example, I would really like to provide you one, but I did not change any code. I just updated the nightly compiler. The latest stable compiles this code without any problems.
Regarding a minimized example, I would really like to provide you one, but I did not change any code. I just updated the nightly compiler. The latest stable compiles this code without any problems.
Sure; it's just substantially more difficult to fix a bug when the input is large as compared to just a few lines of code you can put in a file (and in the playground!). :) Reports with a minimal snippet tend to get fixed much faster and we sorta need a regression test as well.
cc @eddyb @nagisa
The latest stable compiles this code without any problems.
Did you try the beta compiler? Does it work there?
Okay, I tried to find the problem and to reproduce it. I failed at reproducing :(
However, I found the line https://github.com/paritytech/polkadot/blob/master/service/src/lib.rs#L167
If I remove this call to build() it does not crash.
This build call is implemented in the following monstrous impl block: https://github.com/paritytech/substrate/blob/master/core/service/src/builder.rs#L803-L843
I somehow suspect that the where clause could be the reason for it.
Sorry for not being able to reduce it anymore!
I'm currently testing the beta channel and will report back when I know more.
Beta works for me.
I downgraded to "rustc 1.40.0-nightly (c27f7568b 2019-10-13)" and that compiles the crate without any problems.
triage: P-high. self-assigning. removing nomination tag.
Minimal example:
enum Empty {}
enum Enum {
Empty( Empty )
}
fn foobar() -> Option< Enum > {
let value: Option< Empty > = None;
Some( Enum::Empty( value? ) )
}
fn main() {
foobar();
}
It works on stable and on beta; it ICEs on nightly.
Curiously this does not reproduce with ! instead of Empty.
cc @nagisa @eddyb @rkruppe
I believe this is an assert @oli-obk added at my request - it already existed in miri, but was missing from the original implementation in rustc_target::abi.
@eddyb can we remove the assertion for now?
Oops, this slipped into beta (@oli-obk was on vacation and I forgot about it completely).
(to be fair, it was assigned to me, and I just kept letting it slip on my own priority list as well...)
reassigning to @oli-obk based on feedback from compiler team
This regressed here
Most helpful comment
Minimal example:
Playground link.
It works on stable and on beta; it ICEs on nightly.