-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #99207 - 5225225:msan-eager-checks, r=jackh726
Enable eager checks for memory sanitizer Fixes #99179
- Loading branch information
Showing
4 changed files
with
67 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// needs-sanitizer-support | ||
// needs-sanitizer-memory | ||
// min-llvm-version: 14.0.0 | ||
// | ||
// revisions: unoptimized optimized | ||
// | ||
// [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O | ||
// [unoptimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins | ||
// | ||
// run-fail | ||
// error-pattern: MemorySanitizer: use-of-uninitialized-value | ||
// error-pattern: Uninitialized value was created by an allocation | ||
// error-pattern: in the stack frame of function 'random' | ||
// | ||
// This test case intentionally limits the usage of the std, | ||
// since it will be linked with an uninstrumented version of it. | ||
|
||
#![feature(core_intrinsics)] | ||
#![feature(start)] | ||
#![feature(bench_black_box)] | ||
|
||
use std::hint::black_box; | ||
use std::mem::MaybeUninit; | ||
|
||
#[inline(never)] | ||
#[no_mangle] | ||
#[allow(invalid_value)] | ||
fn random() -> char { | ||
let r = unsafe { MaybeUninit::uninit().assume_init() }; | ||
// Avoid optimizing everything out. | ||
black_box(r) | ||
} | ||
|
||
#[start] | ||
fn main(_: isize, _: *const *const u8) -> isize { | ||
random(); | ||
0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters