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

ICE: "Tried to access field 0 of union with 0 fields" #65462

Closed
bkchr opened this issue Oct 16, 2019 · 17 comments · Fixed by #66250
Closed

ICE: "Tried to access field 0 of union with 0 fields" #65462

bkchr opened this issue Oct 16, 2019 · 17 comments · Fixed by #66250
Assignees
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bkchr
Copy link
Contributor

bkchr commented Oct 16, 2019

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:/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: paritytech/polkadot@3174117

Run: BUILD_DUMMY_WASM_BINARY=1 cargo build -p polkadot-service

@Centril
Copy link
Contributor

Centril commented Oct 16, 2019

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.

@Centril Centril added 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. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-nominated labels Oct 16, 2019
@bkchr
Copy link
Contributor Author

bkchr commented Oct 16, 2019

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.

@Centril
Copy link
Contributor

Centril commented Oct 16, 2019

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.

@Centril Centril added the A-codegen Area: Code generation label Oct 16, 2019
@Centril
Copy link
Contributor

Centril commented Oct 16, 2019

cc @eddyb @nagisa

@Centril Centril added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Oct 16, 2019
@Centril
Copy link
Contributor

Centril commented Oct 16, 2019

The latest stable compiles this code without any problems.

Did you try the beta compiler? Does it work there?

@bkchr
Copy link
Contributor Author

bkchr commented Oct 16, 2019

Okay, I tried to find the problem and to reproduce it. I failed at reproducing :(

However, I found the line https:/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:/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.

@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label Oct 16, 2019
@bkchr
Copy link
Contributor Author

bkchr commented Oct 16, 2019

Beta works for me.

@bkchr
Copy link
Contributor Author

bkchr commented Oct 16, 2019

I downgraded to "rustc 1.40.0-nightly (c27f756 2019-10-13)" and that compiles the crate without any problems.

@pnkfelix
Copy link
Member

triage: P-high. self-assigning. removing nomination tag.

@pnkfelix pnkfelix self-assigned this Oct 17, 2019
@pnkfelix pnkfelix added P-high High priority and removed I-nominated labels Oct 17, 2019
@koute
Copy link
Member

koute commented Oct 21, 2019

Minimal example:

enum Empty {}
enum Enum {
    Empty( Empty )
}

fn foobar() -> Option< Enum > {
    let value: Option< Empty > = None;
    Some( Enum::Empty( value? ) )
}

fn main() {
    foobar();
}

Playground link.

It works on stable and on beta; it ICEs on nightly.

@Centril Centril removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Oct 21, 2019
@Centril
Copy link
Contributor

Centril commented Oct 21, 2019

Curiously this does not reproduce with ! instead of Empty.

cc @nagisa @eddyb @rkruppe

@eddyb
Copy link
Member

eddyb commented Oct 23, 2019

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.

@Demi-Marie
Copy link

@eddyb can we remove the assertion for now?

@eddyb
Copy link
Member

eddyb commented Nov 6, 2019

Oops, this slipped into beta (@oli-obk was on vacation and I forgot about it completely).

@Centril Centril added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Nov 6, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Nov 7, 2019

(to be fair, it was assigned to me, and I just kept letting it slip on my own priority list as well...)

@pnkfelix
Copy link
Member

pnkfelix commented Nov 7, 2019

reassigning to @oli-obk based on feedback from compiler team

@pnkfelix pnkfelix assigned oli-obk and unassigned pnkfelix Nov 7, 2019
@spastorino
Copy link
Member

This regressed here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants