Skip to content

Panic (attempt to subtract with overflow) when calculating the number of passed_tests in utils\render_tests.rs #136607

Closed
@anforowicz

Description

@anforowicz

I apologize for not following the bug template + for not having a consistent repro. I hope that opening this issue will still help (writing down and sharing what we know, looping in the author of the line that panics, etc.).

It seems that when running rust tests on Windows, the test binary sometimes (flakily, inconsistently) panics saying (based on two cases when it happened recently - see here and here:

 �[1m�[32m     Running�[0m tests\builtin-clone.rs (build\x86_64-pc-windows-msvc\stage1-std\x86_64-pc-windows-msvc\release\deps\builtin_clone-92ab8a9329f9b62b.exe)
 
 running 1 tests
 
 thread 'main' panicked at src\bootstrap\src\utils\render_tests.rs:230:36:
 attempt to subtract with overflow
 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

So far this has only happened on Windows (and not on Linux). And it seems to only be happening when running tests from library/std/tests/builtin-clone.rs (which contain only a single testcase).

It seems that the line that panics has been introduced relatively recently (around a month ago) in dc11857#diff-218273cbe7a566fb9d2f12187307eb7fd0e4664abd7c375f0f4cd30183ea78c9R230:

```
let passed_tests = self.executed_tests - (self.failures.len() + self.ignored_tests);
```

I guess the panic indicates that self.executed_tests is smaller than the sum of self.failures.len() and self.ignored_tests. This seems rather unexpected.

FWIW This issue is tracked in Chromium's issue tracker as https://crbug.com/392978169.

Metadata

Metadata

Assignees

Labels

A-testsuiteArea: The testsuite used to check the correctness of rustcC-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)T-libsRelevant to the library team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions