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

Nondeterministic compiletest failure on long compiler output #53332

Open
ashtneoi opened this issue Aug 14, 2018 · 5 comments
Open

Nondeterministic compiletest failure on long compiler output #53332

ashtneoi opened this issue Aug 14, 2018 · 5 comments
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@ashtneoi
Copy link
Contributor

ashtneoi commented Aug 14, 2018

If I write a UI test that produces a lot of compiler errors, the test fails with a message like this:

running 1 test
F
failures:

---- [ui] ui/dont-commit.rs stdout ----

error: failed to decode compiler output as json: `EOF while parsing a string at line 1 column 302`
output: {"message":"snipped for brevity"}
line: {"message":"snipped for brevity"}

I can reliably trigger the bug with a UI test like this one:

fn main() {
    let e = 1;
    e = 2;
    e = 2;
    e = 2; // repeated a thousand times or so
}

However, the exact column at which the JSON parse fails is apparently nondeterministic. I ran the test multiple times under varying system load and got 237, 302, and 678. Seems like a race condition to me, although I don't know enough about compiletest to guess where the race might be.

version info

The bug is present on commit 3e05f80.

$ build/x86_64-unknown-linux-gnu/stage1/bin/rustc --version --verbose
rustc 1.30.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.30.0-dev
LLVM version: 7.0
@oli-obk
Copy link
Contributor

oli-obk commented Aug 14, 2018

cc @Zoxc maybe related to parallel rustc things?

@Zoxc
Copy link
Contributor

Zoxc commented Aug 14, 2018

It is probably disabled here. A lot of tests would fail otherwise.

@ashtneoi
Copy link
Contributor Author

ashtneoi commented Aug 16, 2018

Found the problem:

fn into_bytes(self) -> Vec<u8> {
match self {
ProcOutput::Full(bytes) => bytes,
ProcOutput::Abbreviated {
mut head,
skipped,
tail,
} => {
write!(&mut head, "\n\n<<<<<< SKIPPED {} BYTES >>>>>>\n\n", skipped).unwrap();
head.extend_from_slice(&tail);
head
}
}
}
}

So what's happening is compiletest reads the compiler output from a pipe using read2_abbreviated, which throws away the middle of the output if it's too long and inserts a helpful error in its place. Fortunately for us, since the head of the output is almost always truncated in the middle of a line, we get a JSON parse error, rather than a bunch of incorrect "expected error not found" messages (which would have made this harder to debug).

@ashtneoi
Copy link
Contributor Author

I'll see what happens if I change the caller to use read2 directly instead of read2_abbreviated. Fingers crossed that it's that simple.

@ashtneoi
Copy link
Contributor Author

It works! I'll submit a PR and we can work through the finer details there.

scalexm added a commit to scalexm/rust that referenced this issue Nov 24, 2018
@jonas-schievink jonas-schievink added A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. labels Jan 27, 2019
@Enselic Enselic added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Nov 16, 2023
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 C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

5 participants