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 element 1 of array/slice with length 0" (librustc_mir) / const_eval / collect_and_partition_mono_items #53275

Closed
ralfbiedert opened this issue Aug 11, 2018 · 10 comments · Fixed by #70195
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html 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

@ralfbiedert
Copy link
Contributor

When compiling

https://github.com/ralfbiedert/ffsvm-rust/tree/ICE (7ad7b9d78af0984bb909d07107ddcdfc2d3d6b67)

with the command cargo test --verbose I receive the following ICE:

       Fresh unicode-xid v0.0.4                                                                                                                                                                                                        
       Fresh quote v0.3.15
       Fresh cfg-if v0.1.4
       Fresh pest v1.0.6
       Fresh rand_core v0.2.0
       Fresh libc v0.2.33
       Fresh synom v0.11.3
       Fresh packed_simd v0.1.0
       Fresh rand v0.5.0
       Fresh syn v0.11.11
       Fresh simd_aligned v0.1.1
       Fresh pest_derive v1.0.7
   Compiling ffsvm v0.5.0 (file:///Users/rb/Documents/Development/Source/ffsvm-rust)
     Running `rustc --edition=2018 --crate-name svm_class tests/svm_class.rs --emit=dep-info,link -C debuginfo=2 --test -C metadata=90de23b263b45bd4 -C extra-filename=-90de23b263b45bd4 --out-dir /Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps -C incremental=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/incremental -L dependency=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps --extern ffsvm=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps/libffsvm-834cad704ea3a49b.rlib --extern packed_simd=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps/libpacked_simd-9c5bec2e1902d981.rlib --extern pest=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps/libpest-7a901ee692ed4e10.rlib --extern pest_derive=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps/libpest_derive-041426730142ad62.dylib --extern rand=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps/librand-cdbc2f99eb873b42.rlib --extern simd_aligned=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps/libsimd_aligned-7595223b10c560f3.rlib`
thread 'main' panicked at 'Tried to access element 1 of array/slice with length 0', librustc_mir/interpret/place.rs:356:9
stack backtrace:
   0:        0x11330d93f - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::hddb21f2cad89c6a8
   1:        0x1132e63cd - std::sys_common::backtrace::print::h7c325da5eb3eacf5
   2:        0x113316153 - std::panicking::default_hook::{{closure}}::h2e93eff8a7617ec5
   3:        0x113315edc - std::panicking::default_hook::h40768a378fefffb3
   4:        0x111ba22f8 - rustc::util::common::panic_hook::he5eb435dac7dfbda
   5:        0x113316898 - std::panicking::rust_panic_with_hook::h63bac89c0b130b1b
   6:        0x1133163ec - std::panicking::continue_panic_fmt::hca36ebb6f3aa63ac
   7:        0x113316340 - std::panicking::begin_panic_fmt::h96fd014b81747723
   8:        0x110e8a21e - rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::eval_place_projection::hf3b9d24363224386
   9:        0x110e87235 - rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::eval_place::hed294ac41836bd74
  10:        0x110e7e126 - <rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::eval_operand::hd351bd4d141c9108
  11:        0x110e92835 - rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::step::h01a5c690b0510e44
  12:        0x111068c4e - rustc_mir::interpret::const_eval::eval_body_using_ecx::h88f34245fce79395
  13:        0x11106d248 - rustc_mir::interpret::const_eval::const_eval_provider::h5ef6141b9554157b
  14:        0x1117c804a - rustc::ty::query::__query_compute::const_eval::h9236b07a3e0ec26e
  15:        0x1118c6a9f - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval<'tcx>>::compute::h1f4fad381d0aa6a1
  16:        0x11180f7ad - rustc::ty::context::tls::with_context::h4b76755e2f0fe2db
  17:        0x111664048 - rustc::dep_graph::graph::DepGraph::with_task_impl::h897ac5cae53df68c
  18:        0x11186d7a5 - rustc::ty::context::tls::with_related_context::h56ab789e44ae51c4
  19:        0x1118efeee - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job::h67fc91e06e082bda
  20:        0x111a1c798 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query::hf47ecd159ff15a20
  21:        0x111a39199 - rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::const_eval::hc3a415a2c796a3d7
  22:        0x110de9fb9 - rustc_mir::monomorphize::collector::collect_items_rec::hf39d32380d174656
  23:        0x110dea50f - rustc_mir::monomorphize::collector::collect_items_rec::hf39d32380d174656
  24:        0x110dea50f - rustc_mir::monomorphize::collector::collect_items_rec::hf39d32380d174656
  25:        0x110dea50f - rustc_mir::monomorphize::collector::collect_items_rec::hf39d32380d174656
  26:        0x110de90cb - rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}::hc609b4d426ba4e51
  27:        0x110de871c - rustc_mir::monomorphize::collector::collect_crate_mono_items::hd9daffd73591bcec
  28:        0x113f6c48d - rustc::util::common::time::h2b1d2925f85ed468
  29:        0x113ffdec1 - rustc_codegen_llvm::base::collect_and_partition_mono_items::h39da64cc48fe4cc2
  30:        0x1118c7c9b - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::collect_and_partition_mono_items<'tcx>>::compute::h07a9a79a971990a0
  31:        0x111838f94 - rustc::ty::context::tls::with_context::he5ae8e3b22ab295c
  32:        0x11165802c - rustc::dep_graph::graph::DepGraph::with_task_impl::h6fcdb50ec53d7428
  33:        0x1118aa956 - rustc::ty::context::tls::with_related_context::hdd58ffbc49aa25ac
  34:        0x1118dd2fe - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job::h03c2eff4fe067538
  35:        0x1119625fb - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query::h19ee2c093427d6f4
  36:        0x1140060a2 - <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate::h2e345914ae3b3be2
  37:        0x10fdc9e96 - rustc::util::common::time::hedb17545a14fc19e
  38:        0x10fdbe449 - rustc_driver::driver::phase_4_codegen::h96264e40ca32b6e0
  39:        0x10fe4237f - rustc_driver::driver::compile_input::{{closure}}::h25827bf457e1ef39
  40:        0x10fe40ba2 - rustc::ty::context::tls::enter_context::h68d33c1fab936a57
  41:        0x10fdfdc8b - <std::thread::local::LocalKey<T>>::with::hdc92bb8c6dd355c7
  42:        0x10fe5ffd0 - rustc::ty::context::TyCtxt::create_and_enter::h506b011c3ccdd4de
  43:        0x10fdb7e36 - rustc_driver::driver::compile_input::h86bf6ff92f6192bb
  44:        0x10fe46fb2 - rustc_driver::run_compiler_with_pool::h30bb2b1a0187a441
  45:        0x10fda509a - <scoped_tls::ScopedKey<T>>::set::he575ba7defbef56e
  46:        0x10fe170d5 - syntax::with_globals::hf29c42cdb37f02de
  47:        0x10fda441a - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h0e78a384ed94d772
  48:        0x11332279e - __rust_maybe_catch_panic
  49:        0x10fe4428e - rustc_driver::run::hbcb2eda324f678cc
  50:        0x10fe51c4d - rustc_driver::main::hb15a8f8813bab914
  51:        0x10fd3adf5 - std::rt::lang_start::{{closure}}::h658e37a47d5caf6e
  52:        0x113316257 - std::panicking::try::do_call::h9acf80638e52ec84
  53:        0x11332279e - __rust_maybe_catch_panic
  54:        0x1132f6d8c - std::rt::lang_start_internal::h60412e610ba9720a
  55:        0x10fd3ae5b - main
query stack during panic:
#0 [const_eval] const-evaluating `svm_class::m_csvm_linear`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack

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.30.0-nightly (73c78734b 2018-08-05) running on x86_64-apple-darwin

note: compiler flags: -C debuginfo=2 -C incremental

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

error: Could not compile `ffsvm`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name svm_class tests/svm_class.rs --emit=dep-info,link -C debuginfo=2 --test -C metadata=90de23b263b45bd4 -C extra-filename=-90de23b263b45bd4 --out-dir /Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps -C incremental=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/incremental -L dependency=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps --extern ffsvm=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps/libffsvm-834cad704ea3a49b.rlib --extern packed_simd=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps/libpacked_simd-9c5bec2e1902d981.rlib --extern pest=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps/libpest-7a901ee692ed4e10.rlib --extern pest_derive=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps/libpest_derive-041426730142ad62.dylib --extern rand=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps/librand-cdbc2f99eb873b42.rlib --extern simd_aligned=/Users/rb/Documents/Development/Source/ffsvm-rust/target/debug/deps/libsimd_aligned-7595223b10c560f3.rlib` (exit code: 101)

rustup update reports:

info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-x86_64-apple-darwin'
info: checking for self-updates

   stable-x86_64-apple-darwin unchanged - rustc 1.28.0 (9634041f0 2018-07-30)
  nightly-x86_64-apple-darwin unchanged - rustc 1.30.0-nightly (73c78734b 2018-08-05)
@ralfbiedert
Copy link
Contributor Author

The error reproduces on Travis:

https://travis-ci.org/ralfbiedert/ffsvm-rust/builds/414946306

@ralfbiedert
Copy link
Contributor Author

Minimal changes needed to trigger / prevent ICE:

ralfbiedert/ffsvm@344c31f (no ICE)
ralfbiedert/ffsvm@bee2842 (ICE)

@estebank estebank added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html labels Aug 12, 2018
@jonas-schievink jonas-schievink added A-const-eval Area: Constant evaluation (MIR interpretation) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 6, 2019
@oli-obk oli-obk added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Dec 20, 2019
@oli-obk
Copy link
Contributor

oli-obk commented Dec 20, 2019

It would be great if someone could test this on a recent rustc and if it still fails, try to minimize it

@ralfbiedert
Copy link
Contributor Author

I had to update a few files to make it "compile" again, but I still get an ICE with a recent rustc 1.41.0-nightly (c8ea4ace9 2019-12-14):

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `4`,
 right: `0`', src\librustc\mir\interpret\value.rs:305:17
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: <std::io::IoSliceMut as core::fmt::Debug>::fmt
   3: std::panicking::take_hook
   4: std::panicking::take_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: rust_begin_unwind
   8: std::panicking::begin_panic_fmt
   9: <rustc_mir::shim::CallKind as core::fmt::Debug>::fmt
  10: <rustc_mir::transform::remove_noop_landing_pads::RemoveNoopLandingPads as rustc_mir::transform::MirPass>::run_pass
  11: <rustc_mir::transform::remove_noop_landing_pads::RemoveNoopLandingPads as rustc_mir::transform::MirPass>::run_pass
  12: <rustc_mir::transform::remove_noop_landing_pads::RemoveNoopLandingPads as rustc_mir::transform::MirPass>::run_pass
  13: <rustc_mir::transform::remove_noop_landing_pads::RemoveNoopLandingPads as rustc_mir::transform::MirPass>::run_pass
  14: <rustc_mir::transform::remove_noop_landing_pads::RemoveNoopLandingPads as rustc_mir::transform::MirPass>::run_pass
  15: rustc_mir::const_eval::const_eval_raw_provider
  16: <rustc_mir::build::ScopeId as core::fmt::Debug>::fmt
  17: <rustc_mir::shim::CallKind as core::fmt::Debug>::fmt
  18: <rustc_mir::hair::pattern::PatRange as core::fmt::Debug>::fmt
  19: <rustc_mir::shim::CallKind as core::fmt::Debug>::fmt
  20: <rustc_mir::transform::remove_noop_landing_pads::RemoveNoopLandingPads as rustc_mir::transform::MirPass>::run_pass
  21: <rustc_mir::transform::remove_noop_landing_pads::RemoveNoopLandingPads as rustc_mir::transform::MirPass>::run_pass
  22: <rustc_mir::transform::remove_noop_landing_pads::RemoveNoopLandingPads as rustc_mir::transform::MirPass>::run_pass
  23: <rustc_mir::transform::remove_noop_landing_pads::RemoveNoopLandingPads as rustc_mir::transform::MirPass>::run_pass
  24: <rustc_mir::transform::const_prop::ConstPropagator as rustc::mir::visit::MutVisitor>::visit_statement
  25: <rustc_mir::transform::const_prop::ConstProp as rustc_mir::transform::MirPass>::run_pass
  26: rustc_mir::transform::run_passes
  27: rustc_mir::transform::run_passes
  28: rustc_mir::transform::run_passes
  29: rustc::middle::weak_lang_items::<impl rustc::ty::context::TyCtxt>::is_weak_lang_item
  30: rustc::dep_graph::graph::DepGraph::assert_ignored
  31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::try_print_query_stack
  32: rustc::ty::<impl rustc::ty::context::TyCtxt>::instance_mir
  33: rustc_mir::monomorphize::collector::collect_crate_mono_items
  34: rustc_mir::monomorphize::collector::collect_crate_mono_items
  35: rustc_mir::monomorphize::collector::collect_crate_mono_items
  36: <rustc_mir::transform::const_prop::ConstPropagator as rustc::mir::visit::MutVisitor>::visit_terminator
  37: <rustc_mir::interpret::memory::AllocCheck as core::fmt::Debug>::fmt
  38: rustc_mir::monomorphize::collector::collect_crate_mono_items
  39: <rustc_mir::interpret::memory::AllocCheck as core::fmt::Debug>::fmt
  40: rustc_mir::monomorphize::partitioning::compute_codegen_unit_name
  41: <rustc_codegen_llvm::llvm_::archive_ro::Iter as core::ops::drop::Drop>::drop
  42: <rustc_codegen_llvm::back::lto::ThinLTOImports as core::fmt::Debug>::fmt
  43: rustc_codegen_llvm::llvm_::diagnostic::Diagnostic::unpack
  44: <rustc_codegen_llvm::llvm_::ffi::PassKind as core::fmt::Debug>::fmt
  45: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  46: rustc_interface::passes::QueryContext::print_stats
  47: rustc_interface::passes::QueryContext::print_stats
  48: <env_logger::filter::inner::Filter as core::fmt::Debug>::fmt
  49: rustc_interface::queries::Queries::ongoing_codegen
  50: rustc_driver::pretty::print_after_hir_lowering
  51: <syntax_pos::symbol::SymbolStr as core::fmt::Display>::fmt
  52: <rustc::hir::Expr as rustc_typeck::check::coercion::AsCoercionSite>::as_coercion_site
  53: <rustc_driver::Compilation as core::fmt::Debug>::fmt
  54: <rustc_driver::Compilation as core::fmt::Debug>::fmt
  55: _rust_maybe_catch_panic
  56: rustc_driver::pretty::print_after_hir_lowering
  57: ZN244_$LT$std..error..$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$dyn$u20$std..error..Error$u2b$core..marker..Sync$u2b$core..marker..Send$GT$$GT$..from..StringError$u20$as$u20$core..fmt..Display$GT$3fmt17
  58: std::sys::windows::thread::Thread::new
  59: BaseThreadInitThunk
  60: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.41.0-nightly (c8ea4ace9 2019-12-14) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental

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

query stack during panic:
#0 [const_eval_raw] const-evaluating `svm_class::m_csvm_linear`
#1 [optimized_mir] processing `svm_class::m_csvm_linear`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error

error: could not compile `ffsvm`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name svm_class tests\svm_class.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -C debuginfo=2 --test -C metadata=4ed02486dfc162c8 -C extra-filename=-4ed02486dfc162c8 --out-dir D:\Development\Source\ffsvm-rust\target\debug\deps -C incremental=D:\Development\Source\ffsvm-rust\target\debug\incremental -L dependency=D:\Development\Source\ffsvm-rust\target\debug\deps --extern ffsvm=D:\Development\Source\ffsvm-rust\target\debug\deps\libffsvm-526e738465434a2b.rlib --extern packed_simd=D:\Development\Source\ffsvm-rust\target\debug\deps\libpacked_simd-6600a16e46b39a24.rlib --extern pest=D:\Development\Source\ffsvm-rust\target\debug\deps\libpest-4cd557cf2fa26b5a.rlib --extern pest_derive=D:\Development\Source\ffsvm-rust\target\debug\deps\pest_derive-1fd69ab1b51bb5e5.dll --extern rand=D:\Development\Source\ffsvm-rust\target\debug\deps\librand-b0b96e83c985670f.rlib --extern simd_aligned=D:\Development\Source\ffsvm-rust\target\debug\deps\libsimd_aligned-56341438da1a9b6a.rlib` (exit code: 101)

@oli-obk
Copy link
Contributor

oli-obk commented Dec 20, 2019

Awesome! thanks for the quick work.

@oli-obk oli-obk removed the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Dec 21, 2019
@Centril
Copy link
Contributor

Centril commented Mar 10, 2020

@ralfbiedert Do you think you could reduce this further?

@ralfbiedert
Copy link
Contributor Author

I just tried to reproduce this once more with rustc 1.43.0-nightly (564758c4c 2020-03-08) and instead of an ICE it now produces multiple compilation errors, such as:

  --> tests\svm_class.rs:90:5
   |
90 |     test_model!(m_nusvm_poly, "m_nusvm_poly.libsvm", false, [0, 7], []);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: this operation will panic at runtime
  --> tests\svm_class.rs:50:38
   |
50 |                     SVMResult::Label($libsvm_prob[0]),
   |                                      ^^^^^^^^^^^^^^^ index out of bounds: the len is 0 but the index is 0
...
91 |     test_model!(m_nusvm_rbf, "m_nusvm_rbf.libsvm", false, [0, 7], []);
   |     ------------------------------------------------------------------ in this macro invocation
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: reaching this expression at runtime will panic or abort
  --> tests\svm_class.rs:50:38
   |
50 |                     SVMResult::Label($libsvm_prob[0]),
   |                                      ^^^^^^^^^^^^^^^ indexing out of bounds: the len is 0 but the index is 0
...
91 |     test_model!(m_nusvm_rbf, "m_nusvm_rbf.libsvm", false, [0, 7], []);
   |     ------------------------------------------------------------------
   |     |
   |     in this macro invocation
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

This pretty much seems to "prevent" how I could previously ICE it, enabling or disabling macro invocations with an empty array that then got accessed:

// ENABLING THIS LINE TRIGGERS IT:
test_model!(m_csvm_linear, "m_csvm_linear.libsvm", false, [0, 7], []);

Seems like this got fixed.

On a side note, I'm positively surprised it detects this will panic at runtime, although one could make the argument that maybe I wanted that macro expansion to panic inside a #[should_panic] unit test, and therefore emitting a compilation error is too strong.

(Update) Hm, strangely enough, the error generation is only triggered when running cargo test, not when running cargo check (even if I move the invalid array access into the main library). It still doesn't ICE, but it also doesn't produce the errors.

@Centril Centril added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. labels Mar 10, 2020
@Centril
Copy link
Contributor

Centril commented Mar 10, 2020

Cool; ideally, if we could create a minimal example that we could add as a regression test that would be great, and if not, then I guess we'll close the issue as it no longer ICEs.

@ralfbiedert
Copy link
Contributor Author

ralfbiedert commented Mar 10, 2020

Alright, here is the MVP that would do it:

// src/lib.rs

struct S(u8);

pub fn ice() {
    S([][0]);
}

When I run this with cargo build on 1.41.0-nightly (6d77e45f0 2019-12-04) it would ICE as above; with the latest rustc 1.43.0-nightly (564758c4c 2020-03-08) it just gives an error.

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

Centril commented Mar 14, 2020

Thanks, cc @JohnTitor

rylev added a commit to rylev/rust that referenced this issue Mar 20, 2020
Centril added a commit to Centril/rust that referenced this issue Mar 23, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 23, 2020
Rollup of 9 pull requests

Successful merges:

 - rust-lang#68700 (Add Wake trait for safe construction of Wakers.)
 - rust-lang#69494 (Stabilize --crate-version option in rustdoc)
 - rust-lang#70080 (rustc_mir: remove extra space when pretty-printing MIR.)
 - rust-lang#70195 (Add test for issue rust-lang#53275)
 - rust-lang#70199 (Revised span-to-lines conversion to produce an empty vec on DUMMY_SP.)
 - rust-lang#70299 (add err_machine_stop macro)
 - rust-lang#70300 (Reword unused variable warning)
 - rust-lang#70315 (Rename remaining occurences of Void to Opaque.)
 - rust-lang#70318 (Split long derive lists into two derive attributes.)

Failed merges:

r? @ghost
@bors bors closed this as completed in ad6d303 Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html 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.

5 participants