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

crash while downloading sources on osx: index out of bounds: the len is 2 but the index is 2 in cpu.rs #7427

Closed
matthiaskrgr opened this issue Sep 25, 2019 · 1 comment · Fixed by #7429
Labels
C-bug Category: bug

Comments

@matthiaskrgr
Copy link
Member

I saw this on travis ci where cargo crashed while downloading sources https://travis-ci.org/matthiaskrgr/cargo-cache/jobs/589269657#L176

  Downloaded smallvec v0.6.10
  Downloaded nodrop v0.1.13
  Downloaded rustc_version v0.2.3
thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', src/tools/cargo/src/cargo/util/cpu.rs:152:29
stack backtrace:
   0:        0x1067261c5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5e40db06808a02c5
   1:        0x1067502c0 - core::fmt::write::he42958ab73416f43
   2:        0x10671e95b - std::io::Write::write_fmt::h60fdb55d3cacc277
   3:        0x10672989a - std::panicking::default_hook::{{closure}}::h9780f2f769b47a1f
   4:        0x1067295a5 - std::panicking::default_hook::h0208c7cfccea4189
   5:        0x106729ff7 - std::panicking::rust_panic_with_hook::h6c68a3aa4cc51ab7
   6:        0x106729b3d - std::panicking::continue_panic_fmt::h667797a1c6f98cf4
   7:        0x106729a39 - rust_begin_unwind
   8:        0x10674c71f - core::panicking::panic_fmt::ha61f731b713c1136
   9:        0x10674c6d9 - core::panicking::panic_bounds_check::h59db8045e71cfa5b
  10:        0x106293c20 - cargo::util::cpu::imp::current::hb13374f4fa25be14
  11:        0x10626c478 - cargo::core::compiler::job_queue::JobQueue::new::ha5e8b69e006e7f20
  12:        0x10601c444 - cargo::core::compiler::context::Context::compile::h25c90854c2d82f04
  13:        0x10602e990 - cargo::ops::cargo_compile::compile_ws::h99547f1cd1d02754
  14:        0x106029838 - cargo::ops::cargo_compile::compile::h9ddab4fe76991076
  15:        0x105eba626 - cargo::commands::build::exec::ha76e54e95dc52e83
  16:        0x105ec5c6d - cargo::cli::main::hea6e36614a3e7f7f
  17:        0x105f11ddd - cargo::main::ha002fee9b72cb617
  18:        0x105eedb16 - std::rt::lang_start::{{closure}}::h0f2d5194c8bc3f40
  19:        0x1067299b8 - std::panicking::try::do_call::h08253a98d0a78550
  20:        0x10673429f - __rust_maybe_catch_panic
  21:        0x10672a45e - std::rt::lang_start_internal::h7259a5fe6e7e4a74
  22:        0x105f14469 - main
The command "cargo build --all ${RELEASE}" exited with 101.

cargo 1.39.0-nightly (b6c6f685b 2019-09-19)

@matthiaskrgr matthiaskrgr added the C-bug Category: bug label Sep 25, 2019
@matthiaskrgr matthiaskrgr changed the title crash while downloading sources on osx crash while downloading sources on osx: index out of bounds: the len is 2 but the index is 2 in cpu.rs Sep 25, 2019
@jonas-schievink
Copy link
Contributor

Haha, this will panic on any system with <4 processors

cargo/src/cargo/util/cpu.rs

Lines 149 to 154 in 400221e

for chunk in cpu_info.chunks(num_cpus_u as usize) {
ret.user += chunk[CPU_STATE_USER] as u64;
ret.system += chunk[CPU_STATE_SYSTEM] as u64;
ret.idle += chunk[CPU_STATE_IDLE] as u64;
ret.nice += chunk[CPU_STATE_NICE] as u64;
}

alexcrichton added a commit to alexcrichton/cargo that referenced this issue Sep 25, 2019
This should initially help with the panic in rust-lang#7427 but doesn't solve it.
bors added a commit that referenced this issue Sep 25, 2019
Don't ever capture CPU state if timings are disabled

This should initially help with the panic in #7427 but doesn't solve it.
alexcrichton added a commit to alexcrichton/cargo that referenced this issue Sep 25, 2019
This should initially help with the panic in rust-lang#7427 but doesn't solve it.
@bors bors closed this as completed in ab6fa89 Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants