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

Panic index out of bounds running cargo test (unreproducable) #73967

Closed
zhiburt opened this issue Jul 2, 2020 · 0 comments · Fixed by #76256
Closed

Panic index out of bounds running cargo test (unreproducable) #73967

zhiburt opened this issue Jul 2, 2020 · 0 comments · Fixed by #76256
Assignees
Labels
A-incr-comp Area: Incremental compilation 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

@zhiburt
Copy link

zhiburt commented Jul 2, 2020

Follow the compiler's note I decided to unveil this issue 😄

After first time I get the crash I ran cargo test 2 times and each time it was a crash but after that it went normally. I wasn't able to reproduce it.

I don't provide here the code since I consider it unreproducable.

Meta

RUST_BACKTRACE=1 cargo test--verbose:

Backtrace:

thread 'rustc' panicked at 'index out of bounds: the len is 10 but the index is 10', src/librustc_middle/ty/query/on_disk_cache.rs:583:18
note: run with `RUST_BACKTRACE=1` environment variable to display a 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/CONTRIB..

note: rustc 1.44.0 (49cae5576 2020-06-01) running on x86_64-unknown-linux-gnu

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

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

warning: 1 warning emitted

error: could not compile `rstext`.

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

rust-lang/rust
github.com
 
thread 'rustc' panicked at 'index out of bounds: the len is 10 but the index is 10', src/librustc_middle/ty/query/on_disk_cache.rs:583:18
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:78
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:59
4: core::fmt::write
at src/libcore/fmt/mod.rs:1069
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1504
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:62
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:198
9: std::panicking::default_hook
at src/libstd/panicking.rs:218
10: rustc_driver::report_ice
11: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:515
12: rust_begin_unwind
at src/libstd/panicking.rs:419
13: core::panicking::panic_fmt
at src/libcore/panicking.rs:111
14: core::panicking::panic_bounds_check
at src/libcore/panicking.rs:69
15: <rustc_middle::ty::query::on_disk_cache::CacheDecoder as serialize::serialize::SpecializedDecoder<rustc_span::span_encoding::Span»::specialized_decode
16: <rustc_middle::mir::SourceInfo as serialize::serialize::Decodable>::decode
17: <rustc_middle::mir::Statement as serialize::serialize::Decodable>::decode
18: serialize::serialize::Decoder::read_seq
19: <rustc_middle::mir::BasicBlockData as serialize::serialize::Decodable>::decode
20: serialize::serialize::Decoder::read_seq
21: <rustc_middle::mir::Body as serialize::serialize::Decodable>::decode::{{closure}}
22: rustc_middle::ty::query::on_disk_cache::OnDiskCache::try_load_query_result
23: rustc_query_system::query::plumbing::get_query
24: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::instance_mir
25: rustc_mir::monomorphize::collector::collect_items_rec
26: rustc_mir::monomorphize::collector::collect_items_rec
27: rustc_mir::monomorphize::collector::collect_crate_mono_items
28: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
29: 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
30: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
31: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
32: rustc_query_system::query::plumbing::get_query
33: rustc_codegen_ssa::base::codegen_crate
34: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
35: rustc_session::utils::<impl rustc_session::session::Session>::time
36: rustc_interface::passes::start_codegen
37: rustc_middle::ty::context::tls::enter_global
38: rustc_interface::queries::Queries::ongoing_codegen
39: rustc_interface::interface::run_compiler_in_existing_thread_pool
40: scoped_tls::ScopedKey<T>::set
41: rustc_ast::attr::with_globals
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/CONTRIB..

note: rustc 1.44.0 (49cae5576 2020-06-01) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [optimized_mir] processing `it_works::{{closure}}#0`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
warning: 1 warning
 
emitted

error: could not compile `rstext`.

Caused by:
process didn't exit successfully: `rustc —crate-name test —edition=2018 tests/test.rs —error-format=json —json=diagnostic-rendered-ansi —emit=dep-info,link -C debuginfo=2 —test -C metadata=d3af2c6bb91399d2 -C extra-filename=-d3af2c6bb91399d2 —out-dir /home/zhiburt/proj/po-rs/target/debug/deps -C incremental=/home/zhiburt/proj/po-rs/target/debug/incremental -L dependency=/home/zhiburt/proj/po-rs/target/debug/deps —extern rstext=/home/zhiburt/proj/po-rs/target/debug/deps/librstext-96bd2310391f3aca.rlib` (exit code: 101)
@zhiburt zhiburt added the C-bug Category: This is a bug. label Jul 2, 2020
@jonas-schievink jonas-schievink added 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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 2, 2020
@Aaron1011 Aaron1011 self-assigned this Jul 3, 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 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

Successfully merging a pull request may close this issue.

3 participants