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

Nightly ICE regression #46769

Closed
ishitatsuyuki opened this issue Dec 16, 2017 · 4 comments · Fixed by #46808
Closed

Nightly ICE regression #46769

ishitatsuyuki opened this issue Dec 16, 2017 · 4 comments · Fixed by #46808
Labels
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.

Comments

@ishitatsuyuki
Copy link
Contributor

ishitatsuyuki commented Dec 16, 2017

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.24.0-nightly (77efd6800 2017-12-15) running on x86_64-pc-windows-msvc

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`', src\librustc_trans\type_.rs:293:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: Could not compile `select`.
Backtrace
stack backtrace:
   0: <std::fs::DirBuilder as core::fmt::Debug>::fmt
   1: std::sync::condvar::Condvar::new
   2: std::panicking::Location::column
   3: std::panicking::Location::column
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic_fmt
   6: std::panicking::begin_panic_fmt
   7: rustc_trans::type_::Type::padding_filler
   8: <rustc_trans::mir::operand::OperandRef<'tcx> as core::fmt::Debug>::fmt
   9: <rustc::ty::layout::TyLayout<'tcx> as rustc_trans::type_of::LayoutLlvmExt<'tcx>>::llvm_type
  10: <rustc::ty::layout::TyLayout<'tcx> as rustc_trans::type_of::LayoutLlvmExt<'tcx>>::llvm_type
  11: <rustc_trans::abi::CastTarget as core::convert::From<rustc_trans::abi::Uniform>>::from
  12: <&'a rustc_trans::context::CrateContext<'a, 'tcx> as rustc::ty::layout::LayoutOf<&'tcx rustc::ty::TyS<'tcx>>>::layout_of
  13: rustc_trans::trans_item::predefine_fn
  14: rustc_trans::type_::Type::to_ref_slice
  15: rustc_trans::base::trans_crate
  16: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::ensure
  17: rustc::dep_graph::graph::DepGraph::in_ignore
  18: rustc::ty::structural_impls::<impl rustc::ty::context::Lift<'tcx> for rustc::mir::Local>::lift_to_tcx
  19: <rustc::ty::_match::Match<'a, 'gcx, 'tcx> as rustc::ty::relate::TypeRelation<'a, 'gcx, 'tcx>>::tys
  20: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::ensure
  21: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::try_get
  22: rustc::ty::maps::TyCtxtAt::compile_codegen_unit
  23: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::compile_codegen_unit
  24: rustc_trans::base::trans_crate
  25: <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate
  26: rustc_driver::driver::default_provide_extern
  27: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  28: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  29: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  30: <rustc_driver::Compilation as core::fmt::Debug>::fmt
  31: rustc_driver::driver::compile_input
  32: rustc_driver::run_compiler
  33: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt
  34: _rust_maybe_catch_panic
  35: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  36: std::sync::condvar::Condvar::new
  37: std::sys::windows::thread::Thread::new
  38: BaseThreadInitThunk

Windows 10 (64-bit)

@arielb1 arielb1 added 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. labels Dec 17, 2017
@arielb1
Copy link
Contributor

arielb1 commented Dec 17, 2017

@ishitatsuyuki

Which code had caused this assertion?

Details

Caused by this assertion:

pub fn padding_filler(ccx: &CrateContext, size: Size, align: Align) -> Type {
let unit = layout::Integer::approximate_abi_align(ccx, align);
let size = size.bytes();
let unit_size = unit.size().bytes();
assert_eq!(size % unit_size, 0);
Type::array(&Type::from_integer(ccx, unit), size / unit_size)
}

Which was introduced in #46623, which is beta-nominated. cc @eddyb

@eddyb
Copy link
Member

eddyb commented Dec 17, 2017

I'm glad I added that assertion! What it likely means is that size isn't a multiple of align.
I'd be quite surprised if #[repr(packed)] and/or #[repr(align(N))] weren't involved.

@rerz
Copy link

rerz commented Dec 18, 2017

In my case this error is caused by the select crate. Simply including it in your cargo.toml and compiling crashes rustc.

Backtrace
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at /checkout/src/libstd/sys_common/backtrace.rs:68
             at /checkout/src/libstd/sys_common/backtrace.rs:57
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:391
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:538
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:522
   7: rustc_trans::type_::Type::padding_filler
   8: rustc_trans::type_of::struct_llfields
   9: <rustc::ty::layout::TyLayout<'tcx> as rustc_trans::type_of::LayoutLlvmExt<'tcx>>::llvm_type
  10: rustc_trans::abi::FnType::llvm_type
  11: rustc_trans::declare::declare_fn
  12: rustc_trans::trans_item::predefine_fn
  13: rustc_trans::trans_item::TransItemExt::predefine
  14: rustc_trans::base::compile_codegen_unit
  15: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::compute_result
  16: rustc::dep_graph::graph::DepGraph::with_task_impl
  17: rustc_errors::Handler::track_diagnostics
  18: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  19: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::force
  20: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::try_get
  21: rustc::ty::maps::TyCtxtAt::compile_codegen_unit
  22: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::compile_codegen_unit
  23: rustc_trans::base::trans_crate
  24: <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate
  25: rustc_driver::driver::phase_4_translate_to_llvm
  26: rustc_driver::driver::compile_input::{{closure}}
  27: <std::thread::local::LocalKey<T>>::with
  28: <std::thread::local::LocalKey<T>>::with
  29: rustc::ty::context::TyCtxt::create_and_enter
  30: rustc_driver::driver::compile_input
  31: rustc_driver::run_compiler

I'm on Arch running the latest nightly rustc.

@eddyb
Copy link
Member

eddyb commented Dec 18, 2017

Looks like Option<(tendril::Tendril<tendril::fmt::UTF8>, bool)> triggers the assertion, and it has alignment 8 but size 17 (which is illegal), IIRC, tendril includes some types that are #[repr(packed)] (or at least in older versions this is indeed 0.3.1 which has a packed Tendril) and has caused issues in the past as well.

EDIT: minimal repro:

#[repr(packed)]
pub struct Packed(&'static (), usize);
pub fn make() -> Option<(Packed, bool)> { None }

bors added a commit that referenced this issue Dec 18, 2017
rustc: ensure optimized enums have a properly aligned size.

Fixes #46769 by padding the optimized enums wrapping packed data as necessary.

Note that this is not the only way to solve this - on nightly, #46436 makes it easier to fix without adding new padding because of the replacement of `packed` flags with a non-redundant scheme.
But because it can't be backported, the optimal fix will be in a separate nightly-only PR (#46809).
kennytm added a commit to kennytm/rust that referenced this issue Dec 21, 2017
 rustc: do not raise the alignment of optimized enums to the niche's alignment.

This is the improved fix for rust-lang#46769 that does not increase the size of any types (see also rust-lang#46808).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants