Skip to content

fix compiletest crash #113246

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

Merged
merged 1 commit into from
Jul 6, 2023
Merged

Conversation

mirkootter
Copy link
Contributor

Motivation

When running compiler-tests locally for the wasm32 platform, one test repeatedly crashed. It does not crash on the CI, only locally. Investigation shows that the compiletest itself crashes

panicked-at-attempt-to-subtract-with-overflow

let mut head = replace(bytes, Vec::new());
let mut middle = head.split_off(HEAD_LEN);

// The following line will panic
let tail = middle.split_off(middle.len() - TAIL_LEN).into_boxed_slice();
let skipped = new_len - HEAD_LEN - TAIL_LEN;

Background

The code in question collects the output of a process. Small output is kept completely, but larger output is kept only partially: the first 160 kB and the last 256 kB.

The code that performs this split crashes if the data size is less than 416 kB. There is an early out based on the "filtered" length, but it is possible that the filtered length is greater than the real length. It seems that this code was written with the assumption that the filtered length is larger than the real length, which is not true in general.

When running CI tests locally using src/ci/docker/run.sh, the filtered folder is /checkout, which is shorter than the placeholder length of 32 bytes.

Note

This PR should not change any behaviour. It only adds an early our for a case which will definitely crash (at least if compiletest is build with integer checks).

Note that an early out makes sense here: If the real data is too small, it does not sense to split it.

@rustbot
Copy link
Collaborator

rustbot commented Jul 1, 2023

r? @wesleywiser

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 1, 2023
@mirkootter
Copy link
Contributor Author

@pietroalbini Maybe you can have a look? Most of this is based on your work.

@wesleywiser
Copy link
Member

r? @pietroalbini

@rustbot rustbot assigned pietroalbini and unassigned wesleywiser Jul 3, 2023
@pietroalbini
Copy link
Member

@bors r+

Good catch!

@bors
Copy link
Collaborator

bors commented Jul 6, 2023

📌 Commit 3ed2b46 has been approved by pietroalbini

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 6, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 6, 2023
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#112295 (Fix the tests-listing-format-json test on Windows)
 - rust-lang#113246 (fix compiletest crash)
 - rust-lang#113395 (Dont ICE for `dyn* Trait: Trait` (built-in object) goals during selection in new trait solver)
 - rust-lang#113402 (Diagnose unsorted CGUs.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1bb5dd6 into rust-lang:master Jul 6, 2023
@rustbot rustbot added this to the 1.72.0 milestone Jul 6, 2023
@mirkootter mirkootter deleted the fix-compiletest-crash branch July 6, 2023 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants