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 error on nightly (since April 28th): librustc/ty/layout.rs:1002: impossible case reached #50442

Closed
cipriancraciun opened this issue May 4, 2018 · 9 comments
Assignees
Labels
A-typesystem Area: The type system C-bug Category: This is a bug. 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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@cipriancraciun
Copy link

I have a "largish" piece of code that fails to build with any nightly compilers since April 28th. The latest to work was April 27th.

The error is:

error: internal compiler error: librustc/ty/layout.rs:1002: impossible case reached
thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
[...]
  99: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
query stack during panic:
#0 [layout_raw] computing layout of `primitives_procedures::ProcedurePrimitive0`
#1 [layout_raw] computing layout of `primitives_procedures::ProcedurePrimitive`
#2 [layout_raw] computing layout of `values_value::Value`
#3 [layout_raw] computing layout of `std::option::Option<values_value::Value>`
#4 [layout_raw] computing layout of `contexts::BindingTemplate`
#5 [layout_raw] computing layout of `std::option::Option<contexts::BindingTemplate>`
#6 [layout_raw] computing layout of `compiler::CompilerBinding`
end of query stack
error: aborting due to previous error

In order to reproduce this error, and to check the last nightly that works, bellow are the bash snippets that clone the repository, install the two nightlies via rust-up in the current folder, and execute the compilation:

  • get the sources:
git clone --depth=1 -- https://github.com/cipriancraciun/vonuvoli-scheme.git ./vonuvoli-scheme
cd -- ./vonuvoli-scheme
  • prepare the rust-up environment:
mkdir -- ./.rust ./.rust/rustup ./.rust/cargo

curl -s -o ./.rust/rustup-init.tmp -- https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init
mv -n -T -- ./.rust/rustup-init.tmp ./.rust/rustup-init
chmod +x -- ./.rust/rustup-init

export -- RUSTUP_HOME="${PWD}/.rust/rustup"
export -- CARGO_HOME="${PWD}/.rust/cargo"
export -- RUST_BACKTRACE=1
  • install the two nightly versions:
./.rust/rustup-init -y --no-modify-path
./.rust/cargo/bin/rustup install nightly-2018-04-27
./.rust/cargo/bin/rustup install nightly-2018-05-04
  • compile with success by using the April 27th version of nightly:
./.rust/cargo/bin/cargo +nightly-2018-04-27 build --lib --no-default-features
  • compile with failure by using the latest version (at the moment of writing) of nightly:
./.rust/cargo/bin/cargo +nightly-2018-05-04 build --lib --no-default-features

The full output obtained from rustc is bellow:

   Compiling vonuvoli-scheme v0.1.0 (file:///home/ciprian/vonuvoli-scheme)
error: internal compiler error: librustc/ty/layout.rs:1002: impossible case reached

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:467
   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::ty::layout::LayoutCx<'tcx, rustc::ty::context::TyCtxt<'a, 'tcx, 'tcx>>>::layout_raw_uncached
  15: rustc::ty::context::tls::with_related_context
  16: rustc::ty::layout::layout_raw
  17: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::layout_raw<'tcx>>::compute
  18: rustc::ty::context::tls::with_context
  19: rustc::dep_graph::graph::DepGraph::with_task_impl
  20: rustc::ty::context::tls::with_related_context
  21: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  22: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  23: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once
  24: <&'a mut I as core::iter::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  26: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  27: <rustc::ty::layout::LayoutCx<'tcx, rustc::ty::context::TyCtxt<'a, 'tcx, 'tcx>>>::layout_raw_uncached
  28: rustc::ty::context::tls::with_related_context
  29: rustc::ty::layout::layout_raw
  30: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::layout_raw<'tcx>>::compute
  31: rustc::ty::context::tls::with_context
  32: rustc::dep_graph::graph::DepGraph::with_task_impl
  33: rustc::ty::context::tls::with_related_context
  34: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  35: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  36: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once
  37: <&'a mut I as core::iter::iterator::Iterator>::next
  38: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  39: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  40: <rustc::ty::layout::LayoutCx<'tcx, rustc::ty::context::TyCtxt<'a, 'tcx, 'tcx>>>::layout_raw_uncached
  41: rustc::ty::context::tls::with_related_context
  42: rustc::ty::layout::layout_raw
  43: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::layout_raw<'tcx>>::compute
  44: rustc::ty::context::tls::with_context
  45: rustc::dep_graph::graph::DepGraph::with_task_impl
  46: rustc::ty::context::tls::with_related_context
  47: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  48: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  49: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once
  50: <&'a mut I as core::iter::iterator::Iterator>::next
  51: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  52: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  53: <rustc::ty::layout::LayoutCx<'tcx, rustc::ty::context::TyCtxt<'a, 'tcx, 'tcx>>>::layout_raw_uncached
  54: rustc::ty::context::tls::with_related_context
  55: rustc::ty::layout::layout_raw
  56: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::layout_raw<'tcx>>::compute
  57: rustc::ty::context::tls::with_context
  58: rustc::dep_graph::graph::DepGraph::with_task_impl
  59: rustc::ty::context::tls::with_related_context
  60: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  61: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  62: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once
  63: <&'a mut I as core::iter::iterator::Iterator>::next
  64: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  65: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  66: <rustc::ty::layout::LayoutCx<'tcx, rustc::ty::context::TyCtxt<'a, 'tcx, 'tcx>>>::layout_raw_uncached
  67: rustc::ty::context::tls::with_related_context
  68: rustc::ty::layout::layout_raw
  69: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::layout_raw<'tcx>>::compute
  70: rustc::ty::context::tls::with_context
  71: rustc::dep_graph::graph::DepGraph::with_task_impl
  72: rustc::ty::context::tls::with_related_context
  73: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  74: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  75: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once
  76: <&'a mut I as core::iter::iterator::Iterator>::next
  77: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  78: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  79: <rustc::ty::layout::LayoutCx<'tcx, rustc::ty::context::TyCtxt<'a, 'tcx, 'tcx>>>::layout_raw_uncached
  80: rustc::ty::context::tls::with_related_context
  81: rustc::ty::layout::layout_raw
  82: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::layout_raw<'tcx>>::compute
  83: rustc::ty::context::tls::with_context
  84: rustc::dep_graph::graph::DepGraph::with_task_impl
  85: rustc::ty::context::tls::with_related_context
  86: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  87: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  88: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once
  89: <&'a mut I as core::iter::iterator::Iterator>::next
  90: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  91: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  92: <rustc::ty::layout::LayoutCx<'tcx, rustc::ty::context::TyCtxt<'a, 'tcx, 'tcx>>>::layout_raw_uncached
  93: rustc::ty::context::tls::with_related_context
  94: rustc::ty::layout::layout_raw
  95: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::layout_raw<'tcx>>::compute
  96: rustc::ty::context::tls::with_context
  97: rustc::dep_graph::graph::DepGraph::with_task_impl
  98: rustc::ty::context::tls::with_related_context
  99: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
query stack during panic:
#0 [layout_raw] computing layout of `primitives_procedures::ProcedurePrimitive0`
#1 [layout_raw] computing layout of `primitives_procedures::ProcedurePrimitive`
#2 [layout_raw] computing layout of `values_value::Value`
#3 [layout_raw] computing layout of `std::option::Option<values_value::Value>`
#4 [layout_raw] computing layout of `contexts::BindingTemplate`
#5 [layout_raw] computing layout of `std::option::Option<contexts::BindingTemplate>`
#6 [layout_raw] computing layout of `compiler::CompilerBinding`
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.27.0-nightly (e82261dfb 2018-05-03) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=32 -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `vonuvoli-scheme`.

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

If need I can try to use a different build, arguments, etc.

Hope it helps in finding the issue,
Ciprian.

@cuviper cuviper added A-typesystem Area: The type system 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. C-bug Category: This is a bug. labels May 4, 2018
@cramertj cramertj added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label May 4, 2018
@pietroalbini pietroalbini added this to the 1.27 milestone May 7, 2018
@bytwise
Copy link
Contributor

bytwise commented May 7, 2018

I got the same ICE with rustc 1.27.0-nightly (428ea5f6b 2018-05-06) and could reduce it to the following https://play.rust-lang.org/?gist=2302770d40b839577492d146542b1471&version=nightly&mode=debug

@pietroalbini pietroalbini added regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels May 9, 2018
@nikomatsakis
Copy link
Contributor

Is there any chance we can bisect this? The https://github.com/rust-lang-nursery/cargo-bisect-rustc tool may be of use. It'd be great if we could narrow this down to a specific PR. That said, I'll cc @eddyb since they tend to be the owner of the layout code.

@nikomatsakis
Copy link
Contributor

cc @nox

@nikomatsakis
Copy link
Contributor

Well I guess the original poster already narrowed down Apr 27 as the "last working nightly", so that should help (though the cargo-bisect-rustc tool could identify the specific PR)

@nikomatsakis nikomatsakis added the P-high High priority label May 10, 2018
@nikomatsakis
Copy link
Contributor

@nox thinks this is likely the same issue as #50371, assigning to them.

@nox
Copy link
Contributor

nox commented May 10, 2018

Not the same issue as #50371, but still the same issue as something we found with @eddyb on some other patch that didn't land yet, and we didn't realise it could already happen. I have a patch for it, now I just need to write a test that demonstrates the issue.

@eddyb
Copy link
Member

eddyb commented May 10, 2018

It's something that shouldn't be possible, given the code. I think it could be a compiler miscompilation. In any case, the bug!() should be changed to provide as much information as possible, and the testcase attempted with the changed compiler.

EDIT: nevermind it's "just" uninhabited structs being "unions".
EDIT2: I will mark this as fixed in a PR which changes uninhabited structs to never be unions.

@nox nox assigned eddyb and unassigned nox May 10, 2018
@eddyb
Copy link
Member

eddyb commented May 10, 2018

Minimal reproduction by guessing from the code:

enum Void {}
enum Foo { A(i32), B(Void), C(i32) }

bors added a commit that referenced this issue May 13, 2018
rustc: leave space for fields of uninhabited types to allow partial initialization.

Fixes #49298 by only collapsing uninhabited enum variants, and only if they only have ZST fields.
Fixes #50442 incidentally (@nox's optimization didn't take into account uninhabited variants).
@cipriancraciun
Copy link
Author

I confirm that with the latest nightly (2018-05-13) it compiles just fine.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system C-bug Category: This is a bug. 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. 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

8 participants