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 while building nalgebra with mir-opt-level 3: ErrorReported in rustc_mir/src/transform/inline/cycle.rs #82650

Closed
matthiaskrgr opened this issue Mar 1, 2021 · 8 comments
Labels
A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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

@matthiaskrgr
Copy link
Member

git clone  https://github.com/dimforge/nalgebra
cd nalgebra
git checkout fccc42601d74b3d5812b967a94f14b4e175ef7b9 
RUST_BACKTRACE=full  RUSTFLAGS="-Zmir-opt-level=3" cargo build 

Meta

rustc --version --verbose:

rustc 1.52.0-nightly (e37a13cc3 2021-02-28)
binary: rustc
commit-hash: e37a13cc3594004663738bd18d8100e6db9666cf
commit-date: 2021-02-28
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1

Error output

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: ErrorReported', compiler/rustc_mir/src/transform/inline/cycle.rs:47:86

Backtrace

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: ErrorReported', compiler/rustc_mir/src/transform/inline/cycle.rs:47:86
stack backtrace:
   0:     0x7fde53c05eb0 - std::backtrace_rs::backtrace::libunwind::trace::h9d49145f95eb5894
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7fde53c05eb0 - std::backtrace_rs::backtrace::trace_unsynchronized::hab1d020365bb6864
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fde53c05eb0 - std::sys_common::backtrace::_print_fmt::h7659588431e304bd
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fde53c05eb0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h09f4a9e3befae3c7
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fde53c765dc - core::fmt::write::hf3fdfde304b9a088
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/core/src/fmt/mod.rs:1092:17
   5:     0x7fde53bf91f2 - std::io::Write::write_fmt::h1cb850689c7116f0
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/io/mod.rs:1568:15
   6:     0x7fde53c09d55 - std::sys_common::backtrace::_print::hdbccd5aa093ba544
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fde53c09d55 - std::sys_common::backtrace::print::hc639c4f320222558
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fde53c09d55 - std::panicking::default_hook::{{closure}}::hdb012dd7a485bb5d
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/panicking.rs:208:50
   9:     0x7fde53c09803 - std::panicking::default_hook::h75facbce77b6ba91
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/panicking.rs:225:9
  10:     0x7fde543fc9cb - rustc_driver::report_ice::h01b4629c250edc77
  11:     0x7fde53c0a656 - std::panicking::rust_panic_with_hook::hbcaa5de2cb5e22d5
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/panicking.rs:595:17
  12:     0x7fde53c0a177 - std::panicking::begin_panic_handler::{{closure}}::h4ee6cde415c8f62d
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/panicking.rs:497:13
  13:     0x7fde53c0636c - std::sys_common::backtrace::__rust_end_short_backtrace::h895319f2d3f611c0
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7fde53c0a0d9 - rust_begin_unwind
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/panicking.rs:493:5
  15:     0x7fde53c72a11 - core::panicking::panic_fmt::h0123abb763a6e96f
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/core/src/panicking.rs:92:14
  16:     0x7fde53c72683 - core::option::expect_none_failed::h9fff90ea7603aa1d
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/core/src/option.rs:1300:5
  17:     0x7fde54ed7feb - rustc_mir::transform::inline::cycle::mir_callgraph_reachable::process::h1255075dd1cd194a
  18:     0x7fde54e4b9c8 - rustc_data_structures::stack::ensure_sufficient_stack::he6d1c656006cfa13
  19:     0x7fde54ed7a79 - rustc_mir::transform::inline::cycle::mir_callgraph_reachable::process::h1255075dd1cd194a
  20:     0x7fde54ed721e - rustc_mir::transform::inline::cycle::mir_callgraph_reachable::hddbceb94f795da66
  21:     0x7fde549e3e42 - rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::mir_callgraph_reachable>::compute::h69c98dfc55eda052
  22:     0x7fde54c4626c - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::ha003838df330478f
  23:     0x7fde54b56600 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h72ddeb31be0bca6e
  24:     0x7fde54b6037d - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h6e0bde5c31cf279b
  25:     0x7fde549fee84 - rustc_data_structures::stack::ensure_sufficient_stack::h18d5305f3d0d6957
  26:     0x7fde549a6e40 - rustc_query_system::query::plumbing::force_query_with_job::h7316ac4f4bcaf9fd
  27:     0x7fde5496e152 - rustc_query_system::query::plumbing::get_query_impl::hba3c6ce69c9698de
  28:     0x7fde549dd6d3 - rustc_query_system::query::plumbing::get_query::h9b660a09e2207088
  29:     0x7fde54b9232c - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_callgraph_reachable::hda05ba42bbc58a07
  30:     0x7fde54da29bc - rustc_mir::transform::inline::Inliner::try_inlining::he77d58b3fd231ff5
  31:     0x7fde54da16fa - rustc_mir::transform::inline::Inliner::process_blocks::h930b1f780ac5fb8b
  32:     0x7fde56774b6b - <rustc_mir::transform::inline::Inline as rustc_mir::transform::MirPass>::run_pass::h1328f96fde4168e3
  33:     0x7fde55be1726 - rustc_mir::transform::run_passes::h5ac436b1fed2950c
  34:     0x7fde567795ae - rustc_mir::transform::optimized_mir::h6986e80120ee2c85
  35:     0x7fde5669c288 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h156728fada14a3e6
  36:     0x7fde55a8b4f7 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h5438c615c76b42e1
  37:     0x7fde55a6fa40 - rustc_data_structures::stack::ensure_sufficient_stack::h09961a93b6aecc3b
  38:     0x7fde55a49dda - rustc_query_system::query::plumbing::force_query_with_job::h20ad387fc77c68d7
  39:     0x7fde55a225a6 - rustc_query_system::query::plumbing::get_query_impl::h42993b56ce7fe1ab
  40:     0x7fde55aa269a - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::optimized_mir::hab03db2806a9fb79
  41:     0x7fde55d8d2eb - rustc_metadata::rmeta::encoder::EncodeContext::encode_crate_root::hd2b0983597799f2f
  42:     0x7fde5688f98d - rustc_metadata::rmeta::encoder::encode_metadata_impl::hfe902e1fad4ea0ca
  43:     0x7fde568b5fc1 - rustc_data_structures::sync::join::hc470b3201ec83630
  44:     0x7fde568a104e - rustc_metadata::rmeta::decoder::cstore_impl::<impl rustc_middle::middle::cstore::CrateStore for rustc_metadata::creader::CStore>::encode_metadata::h11438d388eed3603
  45:     0x7fde56b1b320 - rustc_middle::ty::context::TyCtxt::encode_metadata::h9a1ec0fbd747243a
  46:     0x7fde5614da75 - rustc_interface::queries::Queries::ongoing_codegen::hea0e157f127bf881
  47:     0x7fde56101a9e - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h0f61eb416f22a566
  48:     0x7fde561329c1 - rustc_span::with_source_map::h4a0dc647038ad76f
  49:     0x7fde56102a4a - rustc_interface::interface::create_compiler_and_run::h4b294c33113a1bc7
  50:     0x7fde56100b88 - scoped_tls::ScopedKey<T>::set::h3d50179f272e16d1
  51:     0x7fde5610124c - std::sys_common::backtrace::__rust_begin_short_backtrace::h7cf87b5fc59a6baa
  52:     0x7fde5612049a - core::ops::function::FnOnce::call_once{{vtable.shim}}::h8b483ac32d974368
  53:     0x7fde53c1a83a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdc51fe7e73bc86bf
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/alloc/src/boxed.rs:1546:9
  54:     0x7fde53c1a83a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he605738a76b56d9d
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/alloc/src/boxed.rs:1546:9
  55:     0x7fde53c1a83a - std::sys::unix::thread::Thread::new::thread_start::he44b12fd83e74919
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/sys/unix/thread.rs:71:17
  56:     0x7fde53b20299 - start_thread
  57:     0x7fde53a35053 - clone
  58:                0x0 - <unknown>

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.52.0-nightly (e37a13cc3 2021-02-28) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3 -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
#0 [mir_callgraph_reachable] computing if `geometry::rotation_specialization::<impl at src/geometry/rotation_specialization.rs:289:1: 431:2>::new::<base::array_storage::ArrayStorage<N, base::dimension::U3, base::dimension::U1>>` (transitively) calls `base::cg::<impl at src/base/cg.rs:99:1: 204:2>::new_rotation`
#1 [optimized_mir] optimizing MIR for `base::cg::<impl at src/base/cg.rs:99:1: 204:2>::new_rotation`
end of query stack
error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<base::matrix::Matrix<N, base::dimension::U3, base::dimension::U1, base::array_storage::ArrayStorage<N, base::dimension::U3, base::dimension::U1>> as base::unit::Normed>)` during codegen
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:68:32

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1012:13
stack backtrace:
   0:     0x7fde53c05eb0 - std::backtrace_rs::backtrace::libunwind::trace::h9d49145f95eb5894
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7fde53c05eb0 - std::backtrace_rs::backtrace::trace_unsynchronized::hab1d020365bb6864
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fde53c05eb0 - std::sys_common::backtrace::_print_fmt::h7659588431e304bd
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fde53c05eb0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h09f4a9e3befae3c7
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fde53c765dc - core::fmt::write::hf3fdfde304b9a088
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/core/src/fmt/mod.rs:1092:17
   5:     0x7fde53bf91f2 - std::io::Write::write_fmt::h1cb850689c7116f0
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/io/mod.rs:1568:15
   6:     0x7fde53c09d55 - std::sys_common::backtrace::_print::hdbccd5aa093ba544
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fde53c09d55 - std::sys_common::backtrace::print::hc639c4f320222558
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fde53c09d55 - std::panicking::default_hook::{{closure}}::hdb012dd7a485bb5d
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/panicking.rs:208:50
   9:     0x7fde53c09803 - std::panicking::default_hook::h75facbce77b6ba91
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/panicking.rs:225:9
  10:     0x7fde543fc9cb - rustc_driver::report_ice::h01b4629c250edc77
  11:     0x7fde53c0a656 - std::panicking::rust_panic_with_hook::hbcaa5de2cb5e22d5
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/panicking.rs:595:17
  12:     0x7fde53c0a177 - std::panicking::begin_panic_handler::{{closure}}::h4ee6cde415c8f62d
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/panicking.rs:497:13
  13:     0x7fde53c0636c - std::sys_common::backtrace::__rust_end_short_backtrace::h895319f2d3f611c0
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7fde53c0a0d9 - rust_begin_unwind
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/panicking.rs:493:5
  15:     0x7fde53c0a08b - std::panicking::begin_panic_fmt::h0262e6b4d4041adf
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/panicking.rs:435:5
  16:     0x7fde56be1f43 - rustc_errors::HandlerInner::flush_delayed::hc9538a5c5ab9aee8
  17:     0x7fde56be0854 - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::h3720416108e4f7ec
  18:     0x7fde560fc89b - core::ptr::drop_in_place<rustc_session::parse::ParseSess>::h1894c421c112d069
  19:     0x7fde560ffe90 - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::hdf93495fe6008488
  20:     0x7fde5613354d - core::ptr::drop_in_place<rustc_interface::interface::Compiler>::hc3bc67a063544d4a
  21:     0x7fde56132ed1 - rustc_span::with_source_map::h4a0dc647038ad76f
  22:     0x7fde56102a4a - rustc_interface::interface::create_compiler_and_run::h4b294c33113a1bc7
  23:     0x7fde56100b88 - scoped_tls::ScopedKey<T>::set::h3d50179f272e16d1
  24:     0x7fde5610124c - std::sys_common::backtrace::__rust_begin_short_backtrace::h7cf87b5fc59a6baa
  25:     0x7fde5612049a - core::ops::function::FnOnce::call_once{{vtable.shim}}::h8b483ac32d974368
  26:     0x7fde53c1a83a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdc51fe7e73bc86bf
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/alloc/src/boxed.rs:1546:9
  27:     0x7fde53c1a83a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he605738a76b56d9d
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/alloc/src/boxed.rs:1546:9
  28:     0x7fde53c1a83a - std::sys::unix::thread::Thread::new::thread_start::he44b12fd83e74919
                               at /rustc/e37a13cc3594004663738bd18d8100e6db9666cf/library/std/src/sys/unix/thread.rs:71:17
  29:     0x7fde53b20299 - start_thread
  30:     0x7fde53a35053 - clone
  31:                0x0 - <unknown>

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.52.0-nightly (e37a13cc3 2021-02-28) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3 -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
sccache: Compile terminated by signal 4
error: could not compile `nalgebra`

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

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. 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. labels Mar 1, 2021
@JohnTitor JohnTitor added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Mar 1, 2021
@jonas-schievink jonas-schievink added A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining labels Mar 1, 2021
@SNCPlay42
Copy link
Contributor

Reduced:

use std::marker::PhantomData;
use std::ops::{Add, Mul};

pub trait Allocator<N> {
    type Buffer;
}
pub struct DefaultAllocator;
impl<N> Allocator<N> for DefaultAllocator {
    type Buffer = ();
}

pub type Owned<N> = <DefaultAllocator as Allocator<N>>::Buffer;

#[derive(Copy, Clone)]
pub struct Matrix<N> {
    _phantom: PhantomData<N>,
}

pub type Vector4<N> = Matrix<Owned<N>>;

#[derive(Copy, Clone)]
pub struct Quaternion<N = ()> {
    pub coords: Vector4<N>,
}
impl<N> From<Vector4<N>> for Quaternion<N> {
    fn from(_coords: Vector4<N>) -> Self {
        unimplemented!()
    }
}
impl<N> Add for Quaternion<N>
where
    DefaultAllocator: Allocator<N>,
{
    type Output = Quaternion<N>;
    fn add(self, _rhs: Quaternion<N>) -> Self::Output {
        Quaternion::from(self.coords)
    }
}

pub struct DualQuaternion {
    pub real: Quaternion,
    pub dual: Quaternion,
}
impl<'a> Mul<()> for &'a DualQuaternion {
    type Output = ();
    fn mul(self, _rhs: ()) -> () {
        let _ = self.real + self.dual;
    }
}

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Mar 12, 2021

Hm, the reduced code does not reproduce the ice for me. 😕 (wanted to bisect)

@SNCPlay42
Copy link
Contributor

It reproduces on godbolt.

@matthiaskrgr
Copy link
Member Author

Ok it works with --crate-type=lib:
rustc --crate-type=lib bad.rs -Zmir-opt-level=3

@matthiaskrgr
Copy link
Member Author

I wanted to find out which commit introduced the ICE but apparently this already happens since several stable releases, I stopped looking after 1.45.2

@araruna
Copy link

araruna commented May 13, 2021

Ok it works with --crate-type=lib:
rustc --crate-type=lib bad.rs -Zmir-opt-level=3

I was not able to reproduce the ICE using the 1.54.0-nightly on the reduced example, even using this.

$ rustc --version --verbose

rustc 1.54.0-nightly (5c0292654 2021-05-11)
binary: rustc
commit-hash: 5c029265465301fe9cb3960ce2a5da6c99b8dcf2
commit-date: 2021-05-11
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1

@matthiaskrgr
Copy link
Member Author

I am getting this instead now on the crate:

error: internal compiler error: compiler/rustc_traits/src/normalize_erasing_regions.rs:54:32: could not fully normalize `<base::array_storage::ArrayStorage<N, base::dimension::U4, base::dimension::U1> as base::storage::Storage<N, base::dimension::U4>>::RStride`

thread 'rustc' panicked at 'Box<Any>', /rustc/952c5732c2d25a875f90e5cd5dd29a1a21c1d4a2/library/std/src/panic.rs:59:5
stack backtrace:
...

@cjgillot
Copy link
Contributor

cjgillot commented Aug 7, 2022

Fixed by #91743.

@cjgillot cjgillot closed this as completed Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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

No branches or pull requests

6 participants