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

ICE when iterating over a u16 range whose bounds exceed 64k #63364

Closed
apoelstra opened this issue Aug 8, 2019 · 2 comments · Fixed by #63370
Closed

ICE when iterating over a u16 range whose bounds exceed 64k #63364

apoelstra opened this issue Aug 8, 2019 · 2 comments · Fixed by #63370
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@apoelstra
Copy link
Contributor

An ICE is observable with this code:

fn part(_: u16) -> u32 {
    1
}

fn main() {
    for n in 100_000.. {
        let _ = part(n);
    }
}
thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', src/librustc_lint/types.rs:79:12
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

Changing part to take a u32 rather than u16 makes the ICE go away.

Playground link

@thepowersgang
Copy link
Contributor

Investigation shows that 65536 will trigger the ICE, while 65535 will not

@estebank estebank added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 8, 2019
@estebank
Copy link
Contributor

estebank commented Aug 8, 2019

Introduced in 13962af#diff-d4213b0b0cef0ac9073ce6c7a3024192R79

cc @varkor

We can probably get away with doing an early return if eps.len() != 2 and no other changes.

@estebank estebank added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Aug 8, 2019
@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label Aug 8, 2019
bors added a commit that referenced this issue Aug 8, 2019
Rollup of 8 pull requests

Successful merges:

 - #63261 (bump rand in libcore/liballoc test suites)
 - #63316 (Update rustfmt to 1.4.4)
 - #63332 (Add an overflow check in truncate implementation for Unix.)
 - #63342 (Don't use remap-path-prefix in dep-info files.)
 - #63366 (doc: Fix typo in float from bytes methods)
 - #63370 (Fix ICE #63364)
 - #63377 (Improved documentation for compile_error!())
 - #63379 (Add test for issue 53096)

Failed merges:

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants