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

Fix overflow in rustc happening if the err_count() is reduced in a stage. #87761

Merged
merged 1 commit into from
Aug 6, 2021

Conversation

hkratz
Copy link
Contributor

@hkratz hkratz commented Aug 4, 2021

This can happen if stashed diagnostics are removed or replaced with fewer errors. The semantics stay the same if built without overflow checks. Fixes #84219.

Background: I came across this independently by running RUSTFLAGS="-C overflow-checks=on" ./x.py test. Fixing this will allow us to move on and find further overflow errors with testing or fuzzing.

…stage.

This can happen if stashed diagnostics are removed or replaced with fewer errors. The semantics stay the same if built without overflow. Fixes rust-lang#84219.
@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 4, 2021
@jyn514
Copy link
Member

jyn514 commented Aug 5, 2021

Can you add a test for this somehow?

@jyn514 jyn514 added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 5, 2021
@hkratz
Copy link
Contributor Author

hkratz commented Aug 5, 2021

Can you add a test for this somehow?

I don't see a way without enabling overflow checks for the compiler.

@Mark-Simulacrum
Copy link
Member

@bors r+

I'm going to go ahead and approve this - I think in terms of testing we might want to try having a debug-assert builder also enable overflow checks. I'm not confident that this is the right behavior - it's likely more interesting changes are warranted - but for now this'll get us to parity with non overflow checks enabled compilers and the stashed diagnostics problem can be examined separately if needed.

@bors
Copy link
Contributor

bors commented Aug 6, 2021

📌 Commit 5ff06fb has been approved by Mark-Simulacrum

@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 Aug 6, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 6, 2021
…_checks, r=Mark-Simulacrum

Add config.toml options for enabling overflow checks in rustc and std

The names are `overflow-checks` and `overflow-checks-std` and they work similar to  `debug-assertions` and `debug-assertions-std`. Once added we can measure how big the performance impact actually is and maybe enable them for CI tests.

Enabling them already makes two ui tests fail:
```
failures:
    [ui] ui/parser/item-free-const-no-body-semantic-fail.rs
    [ui] ui/parser/item-free-static-no-body-semantic-fail.rs
```
(See rust-lang#84219 and rust-lang#87761.)
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 6, 2021
Rollup of 7 pull requests

Successful merges:

 - rust-lang#85807 (bootstrap: Disable initial-exec TLS model on powerpc)
 - rust-lang#87761 (Fix overflow in rustc happening if the `err_count()` is reduced in a stage.)
 - rust-lang#87775 (Add hint for unresolved associated trait items if the trait has a single item)
 - rust-lang#87779 (Remove special case for statement `NodeId` assignment)
 - rust-lang#87787 (Use `C-unwind` ABI for `__rust_start_panic` in `panic_abort`)
 - rust-lang#87809 (Fix typo in the ptr documentation)
 - rust-lang#87816 (Sync rustc_codegen_cranelift)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3b0e797 into rust-lang:master Aug 6, 2021
@rustbot rustbot added this to the 1.56.0 milestone Aug 6, 2021
@hkratz hkratz deleted the rustc_error_overflow branch August 6, 2021 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Internal Compiler Error: 'attempt to subtract with overflow', compiler/rustc_session/src/session.rs:478:22
7 participants