rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.87k stars 12.52k forks source link

ICE: range start index 2 out of range for slice of length 0', library/core/src/slice/index.rs:52:5 #101268

Closed djc closed 2 years ago

djc commented 2 years ago

Code

Not reduced so far. Can reproduce by checking out the code from https://github.com/InstantDomain/instant-xml/tree/ice and running cargo test (running cargo check is not enough). See the last commit for triggering changes.

Meta

rustc --version --verbose:

rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: aarch64-apple-darwin
release: 1.63.0
LLVM version: 14.0.5

Nightly does not panic.

Error output

thread 'rustc' panicked at 'range start index 2 out of range for slice of length 0', library/core/src/slice/index.rs:52:5

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.63.0 (4b91a6ea7 2022-08-08) running on aarch64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental

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

query stack during panic:
#0 [typeck] type-checking `<impl at instant-xml/tests/all.rs:141:32: 141:39>::deserialize::<impl at instant-xml/tests/all.rs:141:32: 141:39>::visit_struct`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `instant-xml`
Backtrace

``` stack backtrace: 0: 0x104fc3fe0 - ::fmt::h188b7ef1c7993e78 1: 0x105015a54 - core::fmt::write::he84a3004e7af3f34 2: 0x104fb70c0 - std::io::Write::write_fmt::h9370b50affaab0be 3: 0x104fc6c24 - std::panicking::default_hook::{{closure}}::hc074f8023cce83ca 4: 0x104fc698c - std::panicking::default_hook::hef854b51b9b79ff2 5: 0x10c434154 - rustc_driver[8d2050f8429f7bc4]::DEFAULT_HOOK::{closure#0}::{closure#0} 6: 0x104fc71f8 - std::panicking::rust_panic_with_hook::h1e59e224d558a492 7: 0x104fc7090 - std::panicking::begin_panic_handler::{{closure}}::he1a9d6ab32bfd8c6 8: 0x104fc44bc - std::sys_common::backtrace::__rust_end_short_backtrace::he9b94791b02f48cd 9: 0x104fc6de8 - _rust_begin_unwind 10: 0x105043968 - core::panicking::panic_fmt::h9fec86f6a9c4146e 11: 0x105017ee4 - core::slice::index::slice_start_index_len_fail_rt::h688e6b228e353181 12: 0x10500a940 - core::ops::function::FnOnce::call_once::h7f4ad42cb14fdecd 13: 0x105010ec0 - core::intrinsics::const_eval_select::hfb24506f4368c7d5 14: 0x105043a18 - core::slice::index::slice_start_index_len_fail::hb490c535f9720713 15: 0x10fefe174 - ::own_substs 16: 0x10fd711dc - ::visit_expr 17: 0x10fd70dec - ::visit_expr 18: 0x10fd70f24 - ::visit_expr 19: 0x10fd18f08 - ::emit_inference_failure_err 20: 0x10fc11f44 - ::maybe_report_ambiguity 21: 0x10fc03184 - ::report_fulfillment_errors 22: 0x10e8ebdc4 - ::select_all_obligations_or_error 23: 0x10ea075d4 - ::enter::<&rustc_middle[4fa9dd76776bb2aa]::ty::context::TypeckResults, ::enter::{closure#1}, &rustc_middle[4fa9dd76776bb2aa]::ty::context::TypeckResults>::{closure#0}> 24: 0x10e98b970 - rustc_typeck[dc6010940c7a2a65]::check::typeck 25: 0x10f42f684 - >::with_task:: 26: 0x10f1ee388 - rustc_query_system[f18d9eae22d44560]::query::plumbing::try_execute_query::> 27: 0x10f2c30f8 - rustc_query_system[f18d9eae22d44560]::query::plumbing::get_query:: 28: 0x10ea720fc - ::par_body_owners:: 29: 0x10e98f9c0 - rustc_typeck[dc6010940c7a2a65]::check::typeck_item_bodies 30: 0x10f4578e0 - >::with_task:: 31: 0x10f22f5e0 - rustc_query_system[f18d9eae22d44560]::query::plumbing::try_execute_query::> 32: 0x10f292e08 - rustc_query_system[f18d9eae22d44560]::query::plumbing::get_query:: 33: 0x10ea71964 - ::time::<(), rustc_typeck[dc6010940c7a2a65]::check_crate::{closure#7}> 34: 0x10e9fa368 - rustc_typeck[dc6010940c7a2a65]::check_crate 35: 0x10c4bff24 - rustc_interface[db32075e2a9c594e]::passes::analysis 36: 0x10f44fb48 - >::with_task::> 37: 0x10f2245d0 - rustc_query_system[f18d9eae22d44560]::query::plumbing::try_execute_query::>> 38: 0x10f2c354c - rustc_query_system[f18d9eae22d44560]::query::plumbing::get_query:: 39: 0x10c3f666c - ::enter::> 40: 0x10c3d97f0 - ::enter::, rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>> 41: 0x10c3c5bb4 - rustc_span[143ffa354e326ede]::with_source_map::, rustc_interface[db32075e2a9c594e]::interface::create_compiler_and_run, rustc_driver[8d2050f8429f7bc4]::run_compiler::{closure#1}>::{closure#1}> 42: 0x10c3d9fe8 - >::set::, rustc_driver[8d2050f8429f7bc4]::run_compiler::{closure#1}>::{closure#0}, core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>> 43: 0x10c424b68 - std[ad4c17a2ddbcabe2]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver[8d2050f8429f7bc4]::run_compiler::{closure#1}>::{closure#0}, core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>>::{closure#0}, core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>> 44: 0x10c3f8ef8 - <::spawn_unchecked_, rustc_driver[8d2050f8429f7bc4]::run_compiler::{closure#1}>::{closure#0}, core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>>::{closure#0}, core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>>::{closure#1} as core[bae5e8ef542d20e5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 45: 0x104fcfa5c - std::sys::unix::thread::Thread::new::thread_start::h7b2f9b83fb320a20 46: 0x1bc56026c - __pthread_deallocate ```

steffahn commented 2 years ago

Regressed in #89862, fixed in 7e2733bb1dd9afe5fd20370ca4d539d42ac50419 (which contains #98610); probably a duplicate of #98598.