mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
f7287b9a2c
this was a pre-existing latent bug, we just didn't have any CI builders exercising it. fixes the following errors: ``` ---- [ui] tests/ui/sanitize/new-llvm-pass-manager-thin-lto.rs#opt1 stdout ---- error in revision `opt1`: test compilation failed although it shouldn't! status: exit status: 1 command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/sanitize/new-llvm-pass-manager-thin-lto.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=i686-unknown-linux-gnu" "--cfg" "opt1" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--remap-path-prefix=/checkout/tests/ui=fake-test-src-base" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/sanitize/new-llvm-pass-manager-thin-lto.opt1/a" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/i686-unknown-linux-gnu/native/rust-test-helpers" "-Clinker=x86_64-linux-gnu-gcc" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/sanitize/new-llvm-pass-manager-thin-lto.opt1/auxiliary" "-Zsanitizer=address" "-Clto=thin" "-Copt-level=1" --- stderr ------------------------------- error: linking with `x86_64-linux-gnu-gcc` failed: exit status: 1 = note: x86_64-linux-gnu-gcc: error: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/i686-unknown-linux-gnu/lib/librustc-nightly_rt.asan.a: No such file or directory failures: [ui] tests/ui/sanitize/badfree.rs [ui] tests/ui/sanitize/address.rs [ui] tests/ui/sanitize/use-after-scope.rs [ui] tests/ui/sanitize/new-llvm-pass-manager-thin-lto.rs#opt0 [ui] tests/ui/sanitize/new-llvm-pass-manager-thin-lto.rs#opt1 ```
20 lines
477 B
Rust
20 lines
477 B
Rust
// needs-sanitizer-support
|
|
// needs-sanitizer-address
|
|
// ignore-cross-compile
|
|
//
|
|
// compile-flags: -Z sanitizer=address -O -g
|
|
//
|
|
// run-fail
|
|
// error-pattern: AddressSanitizer: stack-buffer-overflow
|
|
// error-pattern: 'xs' (line 14) <== Memory access at offset
|
|
|
|
use std::hint::black_box;
|
|
|
|
fn main() {
|
|
let xs = [0, 1, 2, 3];
|
|
// Avoid optimizing everything out.
|
|
let xs = black_box(xs.as_ptr());
|
|
let code = unsafe { *xs.offset(4) };
|
|
std::process::exit(code);
|
|
}
|