-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Closed
Labels
I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessO-windowsOperating system: WindowsOperating system: WindowsP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
With avx and lto enabled, index out of bounds causes a STATUS_ACCESS_VIOLATION instead of a panic. Initially encountered this problem in a program using rand::thread_rng() but narrowed down to a simpler test case found in issue #51794.
I tried this code:
fn main() {
let x = [1];
let i = 1;
println!("{}", x[i]);
}
with flags -C lto -C target-feature=+avx
I expected to see this happen:
PS > cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target\debug\rand_test.exe`
thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', src\main.rs:5:20
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: process didn't exit successfully: `target\debug\rand_test.exe` (exit code: 101)
Instead, this happened:
PS > cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target\debug\rand_test.exe`
error: process didn't exit successfully: `target\debug\rand_test.exe` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
Meta
rustc 1.36.0 (a53f9df 2019-07-03)
binary: rustc
commit-hash: a53f9df
commit-date: 2019-07-03
host: x86_64-pc-windows-msvc
release: 1.36.0
LLVM version: 8.0
lldb output:
(lldb) target create "target\\debug\\rand_test.exe"
Current executable set to 'target\debug\rand_test.exe' (x86_64).
(lldb) run
Process 6676 launched: 'target\debug\rand_test.exe' (x86_64)
Process 6676 stopped
* thread #1, stop reason = Exception 0xc0000005 encountered at address 0x13f0d6175
frame #0: 0x000000013f0d6175 rand_test.exe
-> 0x13f0d6175: vmovaps 0x60(%rcx), %ymm0
0x13f0d617d: movl $0x1, %edx
0x13f0d6182: vmovq %rdx, %xmm1
0x13f0d6187: vmovaps %xmm1, %xmm2
Metadata
Metadata
Labels
I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessO-windowsOperating system: WindowsOperating system: WindowsP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.