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

repr(packed) triggers internal compiler error #48638

Closed
robsmith11 opened this issue Mar 1, 2018 · 9 comments · Fixed by #65395
Closed

repr(packed) triggers internal compiler error #48638

robsmith11 opened this issue Mar 1, 2018 · 9 comments · Fixed by #65395
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been 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.

Comments

@robsmith11
Copy link

Minimal example:

extern crate nalgebra;
use nalgebra::*;

#[repr(packed)]
struct S {
    x:Vector1<f64>,
}

fn main() {
}
$ rustc -vV
rustc 1.26.0-nightly (0ff9872b2 2018-02-28)
binary: rustc
commit-hash: 0ff9872b2280009f094af0df3dcdc542cc46a5fd
commit-date: 2018-02-28
host: x86_64-unknown-linux-gnu
release: 1.26.0-nightly
LLVM version: 6.0
$ cargo build
   Compiling err v0.1.0 (file:///tmp/err)
error: internal compiler error: librustc_typeck/check/wfcheck.rs:243: inference variables in nalgebra::Matrix<f64, nalgebra::U1, nalgebra::U1, nal\
gebra::MatrixArray<_, _, _>>
 --> src/main.rs:5:1
  |
5 | / struct S {
6 | |     x:Vector1<f64>,
7 | | }
  | |_^

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:482:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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
   2: std::panicking::default_hook::{{closure}}
             at libstd/sys_common/backtrace.rs:59
             at libstd/panicking.rs:206
   3: std::panicking::default_hook
             at libstd/panicking.rs:222
   4: core::ops::function::Fn::call
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:401
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::span_bug
   8: rustc::session::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: <std::thread::local::LocalKey<T>>::try_with
  11: <std::thread::local::LocalKey<T>>::with
  12: rustc::ty::context::tls::with
  13: rustc::ty::context::tls::with_opt
  14: rustc::session::opt_span_bug_fmt
  15: rustc::session::span_bug_fmt
  16: rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor::check_type_defn::{{closure}}::{{closure}}::{{closure}}
  17: rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor::check_item_well_formed
  18: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'v>>::visit_item
  19: rustc_typeck::check_crate::{{closure}}
  20: rustc_typeck::check_crate
  21: rustc::ty::context::TyCtxt::create_and_enter
  22: rustc_driver::driver::compile_input
  23: rustc_driver::run_compiler

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.26.0-nightly (0ff9872b2 2018-02-28) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental -C target-cpu=native --crate-type bin
@estebank estebank added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 1, 2018
@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 13, 2018

@bitshifter can you reproduce?

@bitshifter
Copy link
Contributor

@gnzlbg I can try, this is from Mar 2nd so not related to my recent changes right?

@bitshifter
Copy link
Contributor

@gnzlbg yes it fails for me with both stable rust 1.25 and the latest nightly rustc 1.27.0-nightly (ad610be 2018-04-11). It's not failing in a part of typeck that I'm familiar with but I'll have a look sometime and see if it makes any sense to me.

@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 13, 2018

Yes this is unrelated to that PR (I think there isn't a nightly including it yet). But since this is related to packed I thought you might want to take a look.

@bitshifter
Copy link
Contributor

I started expanding the minimal example so that it didn't depend on nalgebra, it has expanded into quite a lot of code https://gist.github.com/bitshifter/afa4a3403802eebf9516ae7c3d174ba8

This example is enough to break the compiler but doesn't compile if the ICE is fixed (e.g. if the #[repr(packed)] is commented out). For it to compile it still needs some external dependencies.

It appears to be the associated type that is hitting the ICE.

@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 14, 2018

Yeah @robsmith11 's example is huge. Maybe he doesn't know that minimal examples should have no dependencies. @robsmith11 if you don't provide minimal examples in bug reports (that is: no dependencies; they should compile in the play ground) they'll take much longer than necessary to fix.

@robsmith11
Copy link
Author

@gnzlbg
I understand. I'm a relative beginner to rust, so it would take quite a lot of time for me to figure out how to make a more minimal example.

I am able to work around this issue in my own code, so it's not that important to me, but I figured it might be easy for someone more experienced to spot what was going wrong. If you don't think it's worth the effort to investigate further, I have no problem with you closing this until a more simple manifestation is discovered.

@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 14, 2018

I've reduced it to the following (https://play.rust-lang.org/?gist=8678d365f2499392b15f00bc60eb42b8&version=stable):

pub trait D {}
pub struct DT;
impl D for DT {}

pub trait A<R: D>: Sized {
    type AS;
}

pub struct As<R: D>(R);

pub struct AT;
impl<R: D> A<R> for AT {
    type AS = As<R>;
}

#[repr(packed)] // comment to make this pass
struct S(<AT as A<DT>>::AS);

fn main() {}

@XAMPPRocky XAMPPRocky added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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 21, 2018
@JohnTitor
Copy link
Member

It's no longer reproduced an ICE on the latest nightly, it seems from 1.38.0. marked as E-needstest

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 14, 2019
Centril added a commit to Centril/rust that referenced this issue Oct 14, 2019
Add some tests for fixed ICEs

Fixes rust-lang#44153 (from 1.23.0)
Fixes rust-lang#47486 (from 1.36.0)
Fixes rust-lang#48010 (from 1.38.0)
Fixes rust-lang#48027 (from nightly)
Fixes rust-lang#48638 (from nightly)
@bors bors closed this as completed in a73e073 Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants