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

Index out of bounds in src/librustc_middle/ty/query/on_disk_cache.rs #75900

Closed
Thomasdezeeuw opened this issue Aug 25, 2020 · 2 comments · Fixed by #76256
Closed

Index out of bounds in src/librustc_middle/ty/query/on_disk_cache.rs #75900

Thomasdezeeuw opened this issue Aug 25, 2020 · 2 comments · Fixed by #76256
Labels
A-incr-comp Area: Incremental compilation 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) ❄️

Comments

@Thomasdezeeuw
Copy link
Contributor

     Running `rustc --crate-name heph --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 --test --cfg 'feature="default"' -C metadata=a6343bb67090b08a -C extra-filename=-a6343bb67090b08a --out-dir /Users/thomas/src/heph/target/debug/deps -C incremental=/Users/thomas/src/heph/target/debug/incremental -L dependency=/Users/thomas/src/heph/target/debug/deps --extern crossbeam_channel=/Users/thomas/src/heph/target/debug/deps/libcrossbeam_channel-9ecb709bf75fec26.rlib --extern erased_serde=/Users/thomas/src/heph/target/debug/deps/liberased_serde-244fa462d5a596a2.rlib --extern fnv=/Users/thomas/src/heph/target/debug/deps/libfnv-183fbcc1be843e1f.rlib --extern futures_core=/Users/thomas/src/heph/target/debug/deps/libfutures_core-49f8692ca16cde2d.rlib --extern futures_io=/Users/thomas/src/heph/target/debug/deps/libfutures_io-bfe7fe75d07baa83.rlib --extern futures_test=/Users/thomas/src/heph/target/debug/deps/libfutures_test-cbcebeaf29c3e8ec.rlib --extern futures_util=/Users/thomas/src/heph/target/debug/deps/libfutures_util-75d4027bb2349823.rlib --extern lazy_static=/Users/thomas/src/heph/target/debug/deps/liblazy_static-3ac5fd0e5fd029c7.rlib --extern log=/Users/thomas/src/heph/target/debug/deps/liblog-af57844bea540cbf.rlib --extern mio=/Users/thomas/src/heph/target/debug/deps/libmio-c4ff168f4dd8d66c.rlib --extern mio_pipe=/Users/thomas/src/heph/target/debug/deps/libmio_pipe-17e3a1716822c968.rlib --extern mio_signals=/Users/thomas/src/heph/target/debug/deps/libmio_signals-19fc00852f3546dd.rlib --extern num_cpus=/Users/thomas/src/heph/target/debug/deps/libnum_cpus-8173e222e24ff8b3.rlib --extern parking_lot=/Users/thomas/src/heph/target/debug/deps/libparking_lot-5be69b1765ee7c2a.rlib --extern rand=/Users/thomas/src/heph/target/debug/deps/librand-c15b19e5cece0db1.rlib --extern serde=/Users/thomas/src/heph/target/debug/deps/libserde-e81efd5064d96eed.rlib --extern serde_json=/Users/thomas/src/heph/target/debug/deps/libserde_json-8c8830ac969b650c.rlib --extern std_logger=/Users/thomas/src/heph/target/debug/deps/libstd_logger-5c8cd6509441c993.rlib`
thread 'rustc' panicked at 'index out of bounds: the len is 326 but the index is 326', src/librustc_middle/ty/query/on_disk_cache.rs:706:18
stack backtrace:
   0:        0x10d33b6d4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hfb2db7374ccd4d34
   1:        0x10d3a3260 - core::fmt::write::h7e381316a10f5e82
   2:        0x10d32cf7b - std::io::Write::write_fmt::h53862e22ed93af5e
   3:        0x10d33fff5 - std::panicking::default_hook::{{closure}}::h1a87f1c0565a051b
   4:        0x10d33fd37 - std::panicking::default_hook::he29ab2038604c86f
   5:        0x11174b088 - rustc_driver::report_ice::h20ae032f4c7fea6a
   6:        0x10d3406bd - std::panicking::rust_panic_with_hook::h9dab6d214201c5da
   7:        0x10d34022b - std::panicking::begin_panic_handler::{{closure}}::hf4bcec37fb7265f5
   8:        0x10d33bb18 - std::sys_common::backtrace::__rust_end_short_backtrace::h8c49942bd9c628f8
   9:        0x10d3401ea - _rust_begin_unwind
  10:        0x10d3c82cf - core::panicking::panic_fmt::hc5e2a0be1d842c94
  11:        0x10d3c8296 - core::panicking::panic_bounds_check::h40dfc66b75b71880
  12:        0x1158c674d - rustc_middle::ty::query::on_disk_cache::<impl rustc_serialize::serialize::Decodable<rustc_middle::ty::query::on_disk_cache::CacheDecoder> for rustc_span::span_encoding::Span>::decode::hd82b8a0f436ba20a
  13:        0x115a20f8c - rustc_middle::mir::_DERIVE_rustc_serialize_Decodable_D_FOR_SourceInfo::<impl rustc_serialize::serialize::Decodable<__D> for rustc_middle::mir::SourceInfo>::decode::h695d525836feb3e9
  14:        0x115a257ee - rustc_middle::mir::_DERIVE_rustc_serialize_Decodable_D_FOR_Statement::<impl rustc_serialize::serialize::Decodable<__D> for rustc_middle::mir::Statement>::decode::ha844e1be4cf6fa27
  15:        0x115adeb95 - rustc_serialize::serialize::Decoder::read_seq::h236c3e57c9d48fbd
  16:        0x115a23f54 - rustc_middle::mir::_DERIVE_rustc_serialize_Decodable_D_FOR_BasicBlockData::<impl rustc_serialize::serialize::Decodable<__D> for rustc_middle::mir::BasicBlockData>::decode::hc462cce188981f69
  17:        0x115ae28a5 - rustc_serialize::serialize::Decoder::read_seq::hb93a7c6c475425ee
  18:        0x115a1f7f6 - rustc_middle::mir::_DERIVE_rustc_serialize_Decodable_D_FOR_Body::<impl rustc_serialize::serialize::Decodable<__D> for rustc_middle::mir::Body>::decode::h7066ca664bc07799
  19:        0x115b0580a - rustc_middle::ty::query::on_disk_cache::OnDiskCache::try_load_query_result::h38b1e5e4611933a0
  20:        0x1157add6f - rustc_query_system::query::plumbing::load_from_disk_and_cache_in_memory::he0cb759a6ec37f41
  21:        0x115661f07 - rustc_query_system::query::plumbing::get_query_impl::h6d51c30fcf6c2fe6
  22:        0x115941f08 - rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::instance_mir::h6938b2452d764ed0
  23:        0x1147281d0 - rustc_mir::monomorphize::collector::collect_neighbours::h490ca3a426f530e2
  24:        0x114722d10 - rustc_mir::monomorphize::collector::collect_items_rec::h9f585ad90473302c
  25:        0x114722efb - rustc_mir::monomorphize::collector::collect_items_rec::h9f585ad90473302c
  26:        0x114858d02 - rustc_session::utils::<impl rustc_session::session::Session>::time::h7554db3246046c47
  27:        0x1147217a8 - rustc_mir::monomorphize::collector::collect_crate_mono_items::h290a58418b241f25
  28:        0x114a9d615 - rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items::h3046fc25ee2d49f1
  29:        0x111be9645 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::collect_and_partition_mono_items>::compute::h3b74d27acd4dd78b
  30:        0x111b05a37 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h829d453b57978aac
  31:        0x111b3b9b8 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h9716d60411728c54
  32:        0x111bbec97 - rustc_data_structures::stack::ensure_sufficient_stack::h7cf88ac4f4270b7f
  33:        0x111ac5ac3 - rustc_query_system::query::plumbing::get_query_impl::h7b9b33c7b223c5b6
  34:        0x111bed0aa - rustc_codegen_ssa::base::codegen_crate::h9dfb2043ce1aedbe
  35:        0x111be7e13 - <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::hca41b3ecfc779ff8
  36:        0x1119ed6b0 - rustc_interface::passes::QueryContext::enter::hb64df00a11c266b3
  37:        0x111a22620 - rustc_interface::queries::Queries::ongoing_codegen::he5b6ede59dc680b1
  38:        0x111767b89 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h5f267b10980944aa
  39:        0x1117104ee - rustc_span::with_source_map::h41746b5ad19cb6c9
  40:        0x111769561 - rustc_interface::interface::create_compiler_and_run::hae2e250f665904c6
  41:        0x11174e783 - scoped_tls::ScopedKey<T>::set::h6f614b62c5f7ab14
  42:        0x11175d1df - std::sys_common::backtrace::__rust_begin_short_backtrace::h3e44a6eb413894f0
  43:        0x1116fd45c - core::ops::function::FnOnce::call_once{{vtable.shim}}::h4585fc2219a571d0
  44:        0x10d34eddd - std::sys::unix::thread::Thread::new::thread_start::h39b071b0d2fb7aea
  45:     0x7fff6e5da109 - __pthread_start

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.47.0-nightly (5180f3da5 2020-08-23) running on x86_64-apple-darwin

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

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

query stack during panic:
#0 [optimized_mir] optimizing MIR for `test::test_size_of_actor::{{closure}}#0`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `heph`.

Caused by:
  process didn't exit successfully: `rustc --crate-name heph --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 --test --cfg 'feature="default"' -C metadata=a6343bb67090b08a -C extra-filename=-a6343bb67090b08a --out-dir /Users/thomas/src/heph/target/debug/deps -C incremental=/Users/thomas/src/heph/target/debug/incremental -L dependency=/Users/thomas/src/heph/target/debug/deps --extern crossbeam_channel=/Users/thomas/src/heph/target/debug/deps/libcrossbeam_channel-9ecb709bf75fec26.rlib --extern erased_serde=/Users/thomas/src/heph/target/debug/deps/liberased_serde-244fa462d5a596a2.rlib --extern fnv=/Users/thomas/src/heph/target/debug/deps/libfnv-183fbcc1be843e1f.rlib --extern futures_core=/Users/thomas/src/heph/target/debug/deps/libfutures_core-49f8692ca16cde2d.rlib --extern futures_io=/Users/thomas/src/heph/target/debug/deps/libfutures_io-bfe7fe75d07baa83.rlib --extern futures_test=/Users/thomas/src/heph/target/debug/deps/libfutures_test-cbcebeaf29c3e8ec.rlib --extern futures_util=/Users/thomas/src/heph/target/debug/deps/libfutures_util-75d4027bb2349823.rlib --extern lazy_static=/Users/thomas/src/heph/target/debug/deps/liblazy_static-3ac5fd0e5fd029c7.rlib --extern log=/Users/thomas/src/heph/target/debug/deps/liblog-af57844bea540cbf.rlib --extern mio=/Users/thomas/src/heph/target/debug/deps/libmio-c4ff168f4dd8d66c.rlib --extern mio_pipe=/Users/thomas/src/heph/target/debug/deps/libmio_pipe-17e3a1716822c968.rlib --extern mio_signals=/Users/thomas/src/heph/target/debug/deps/libmio_signals-19fc00852f3546dd.rlib --extern num_cpus=/Users/thomas/src/heph/target/debug/deps/libnum_cpus-8173e222e24ff8b3.rlib --extern parking_lot=/Users/thomas/src/heph/target/debug/deps/libparking_lot-5be69b1765ee7c2a.rlib --extern rand=/Users/thomas/src/heph/target/debug/deps/librand-c15b19e5cece0db1.rlib --extern serde=/Users/thomas/src/heph/target/debug/deps/libserde-e81efd5064d96eed.rlib --extern serde_json=/Users/thomas/src/heph/target/debug/deps/libserde_json-8c8830ac969b650c.rlib --extern std_logger=/Users/thomas/src/heph/target/debug/deps/libstd_logger-5c8cd6509441c993.rlib` (exit code: 101)
@csmoe csmoe added 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) ❄️ labels Aug 25, 2020
@csmoe
Copy link
Member

csmoe commented Aug 25, 2020

@Thomasdezeeuw It'd be great with a minimal reproducible example, or your codebase if it's hard to minimize.

@Thomasdezeeuw
Copy link
Contributor Author

@csmoe I don't have a repro and the code is not open source unfortunately.

@wesleywiser wesleywiser added the A-incr-comp Area: Incremental compilation label Aug 26, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 12, 2020
incr-comp: hash and serialize span end line/column

Hash both the length and the end location (line/column) of a span. If we
hash only the length, for example, then two otherwise equal spans with
different end locations will have the same hash. This can cause a
problem during incremental compilation wherein a previous result for a
query that depends on the end location of a span will be incorrectly
reused when the end location of the span it depends on has changed. A
similar analysis applies if some query depends specifically on the
length of the span, but we only hash the end location. So hash both.

Fix rust-lang#46744, fix rust-lang#59954, fix rust-lang#63161, fix rust-lang#73640, fix rust-lang#73967, fix rust-lang#74890, fix rust-lang#75900

---

See rust-lang#74890 for a more in-depth analysis.

I haven't thought about what other problems this root cause could be responsible for. Please let me know if anything springs to mind. I believe the issue has existed since the inception of incremental compilation.
@bors bors closed this as completed in b71e627 Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation 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) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants