Skip to content

ICE in library/test/src/lib.rs:356 on Nightly when running doc-tests, where the first doc-test is executed twice in a row. #81852

Closed
@yoanlcq

Description

@yoanlcq

Hi,

When running doc-tests with the latest Nightly on my crate, I get an ICE after the first doc-test is executed twice in a row.
The issue does not occur on Stable.
The issue seems to be caused when multiple threads are used for doc-tests.

The ICE is caused by unwrap() in /library/test/src/lib.rs:356.

The issue occured on the x86_64-pc-windows-msvc and x86_64-unknown-linux-gnu targets. Curiously, there are multiple targets on which it does not occur (according to Travic CI builds).
The Travis CI build status is available here : https://travis-ci.com/github/yoanlcq/vek/builds/216330500.

Steps to reproduce

  1. Clone the repo for the vek crate;
  2. Checkout commit a18c2dc5af092caba2daae232d168f1c75c5d039;
  3. Run either cargo test --doc or cargo test --doc -- --test-threads 2.

The actual number of threads does not seem to matter as long as there is more than one.
In my case, specifying -- --test-threads 2 was not necessary, since I think the number of threads is determined automatically in this case.

Code

// No code in particular. The doc-test refers to a line where a macro is expanded.
//
//
// That being said, the line in the compiler's source where the crash occured is : 
let running_test = running_tests.remove(&completed_test.desc).unwrap(); // <--- Unwraps on None

Meta

rustc --version --verbose:

rustc 1.51.0-nightly (04caa632d 2021-01-30)
binary: rustc
commit-hash: 04caa632dd10c2bf64b69524c7f9c4c30a436877
commit-date: 2021-01-30
host: x86_64-pc-windows-msvc
release: 1.51.0-nightly
LLVM version: 11.0.1

Error output

    Finished test [unoptimized + debuginfo] target(s) in 0.03s
   Doc-tests vek

running 1283 tests
test src\mat.rs - mat::repr_c::column_major::mat2::Mat2<T> (line 4154) ... ok
test src\mat.rs - mat::repr_c::column_major::mat2::Mat2<T> (line 4154) ... ok
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', library\test\src\lib.rs:356:75
stack backtrace:
   0:     0x7fff9fee9755 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h07eb7c6246901ad5
   1:     0x7fff9ff15fdb - core::fmt::write::ha3ea633b18d2da75
   2:     0x7fff9fedc08d - <std::io::IoSlice as core::fmt::Debug>::fmt::h8573cdc9b491acbf
   3:     0x7fff9feed8fd - std::panicking::take_hook::h462942ea222a8ec2
   4:     0x7fff9feed3c9 - std::panicking::take_hook::h462942ea222a8ec2
   5:     0x7fff840a96f7 - rustc_driver::report_ice::hc33e4d260fbc44ec
   6:     0x7fff9feee362 - std::panicking::rust_panic_with_hook::h18985e2f09a20bf1
   7:     0x7fff9feede23 - rust_begin_unwind
   8:     0x7fff9feea12f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h07eb7c6246901ad5
   9:     0x7fff9feedda9 - rust_begin_unwind
  10:     0x7fff9ff12070 - core::panicking::panic_fmt::h45da916c710b88f7
  11:     0x7fff9ff11fbc - core::panicking::panic::h3a7a516f2be28c18
  12:     0x7fffbac0cffb - test::test_main_static_abort::h4318bb20d9dc449a
  13:     0x7fffbabf7b72 - test::console::run_tests_console::h6776da77c8860d5d
  14:     0x7fffbac06e77 - test::test_main::h7d9e75411069f83b
  15:     0x7ff6d9c9e2c6 - <unknown>
  16:     0x7ff6d9bb5f77 - <unknown>
  17:     0x7ff6d9d93220 - <unknown>
  18:     0x7ff6d9bc3e0b - <unknown>
  19:     0x7ff6d9d2e69d - <unknown>
  20:     0x7fff9fefe0ca - std::sys::windows::thread::Thread::new::ha39cc759d7fbecd8
  21:     0x7ff8004a7034 - BaseThreadInitThunk
  22:     0x7ff80095d0d1 - RtlUserThreadStart

error: internal compiler error: unexpected panic

error: Unrecognized option: 'test-args'

thread 'src\mat.rs - mat::repr_c::column_major::mat2::Mat2<T> (line 4156)' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', library\test\src\lib.rs:592:30
stack backtrace:
   0:     0x7fff9fee9755 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h07eb7c6246901ad5
   1:     0x7fff9ff15fdb - core::fmt::write::ha3ea633b18d2da75
   2:     0x7fff9fedc08d - <std::io::IoSlice as core::fmt::Debug>::fmt::h8573cdc9b491acbf
   3:     0x7fff9feed8fd - std::panicking::take_hook::h462942ea222a8ec2
   4:     0x7fff9feed3c9 - std::panicking::take_hook::h462942ea222a8ec2
   5:     0x7fff840a96f7 - rustc_driver::report_ice::hc33e4d260fbc44ec
   6:     0x7fff9feee362 - std::panicking::rust_panic_with_hook::h18985e2f09a20bf1
   7:     0x7fff9feede51 - rust_begin_unwind
   8:     0x7fff9feea12f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h07eb7c6246901ad5
   9:     0x7fff9feedda9 - rust_begin_unwind
  10:     0x7fff9ff12070 - core::panicking::panic_fmt::h45da916c710b88f7
  11:     0x7fff9ff11d03 - core::result::unwrap_failed::h8a30362b6787a796
  12:     0x7fffbac17ab2 - test::run_test::h5515debdb9b010cd
  13:     0x7fffbabe15c6 - <unknown>
  14:     0x7fffbabe8cb4 - <unknown>
  15:     0x7fff9fefe0ca - std::sys::windows::thread::Thread::new::ha39cc759d7fbecd8
  16:     0x7ff8004a7034 - BaseThreadInitThunk
  17:     0x7ff80095d0d1 - RtlUserThreadStart

error: internal compiler error: unexpected panic

error: Unrecognized option: 'test-args'

error: test failed, to rerun pass '--doc'
Backtrace

   0:     0x7fff9fee9755 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h07eb7c6246901ad5
   1:     0x7fff9ff15fdb - core::fmt::write::ha3ea633b18d2da75
   2:     0x7fff9fedc08d - <std::io::IoSlice as core::fmt::Debug>::fmt::h8573cdc9b491acbf
   3:     0x7fff9feed8fd - std::panicking::take_hook::h462942ea222a8ec2
   4:     0x7fff9feed3c9 - std::panicking::take_hook::h462942ea222a8ec2
   5:     0x7fff840a96f7 - rustc_driver::report_ice::hc33e4d260fbc44ec
   6:     0x7fff9feee362 - std::panicking::rust_panic_with_hook::h18985e2f09a20bf1
   7:     0x7fff9feede51 - rust_begin_unwind
   8:     0x7fff9feea12f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h07eb7c6246901ad5
   9:     0x7fff9feedda9 - rust_begin_unwind
  10:     0x7fff9ff12070 - core::panicking::panic_fmt::h45da916c710b88f7
  11:     0x7fff9ff11d03 - core::result::unwrap_failed::h8a30362b6787a796
  12:     0x7fffbac17ab2 - test::run_test::h5515debdb9b010cd
  13:     0x7fffbabe15c6 - <unknown>
  14:     0x7fffbabe8cb4 - <unknown>
  15:     0x7fff9fefe0ca - std::sys::windows::thread::Thread::new::ha39cc759d7fbecd8
  16:     0x7ff8004a7034 - BaseThreadInitThunk
  17:     0x7ff80095d0d1 - RtlUserThreadStart

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-libtestArea: `#[test]` / the `test` libraryC-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-libsRelevant to the library team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions