-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #66522 - tmiasko:sanitize-flags, r=alexcrichton
Add support for sanitizer recover and tracking origins of uninitialized memory * Add support for sanitizer recovery `-Zsanitizer-recover=...` (equivalent to `-fsanitize-recover` in clang). * Add support for tracking origins of uninitialized memory in MemorySanitizer `-Zsanitizer-memory-track-origins` (equivalent to `-fsanitize-memory-track-origins` in clang).
- Loading branch information
Showing
7 changed files
with
215 additions
and
32 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
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,28 @@ | ||
// Verifies that MemorySanitizer track-origins level can be controlled | ||
// with -Zsanitizer-memory-track-origins option. | ||
// | ||
// needs-sanitizer-support | ||
// only-linux | ||
// only-x86_64 | ||
// revisions:MSAN-0 MSAN-1 MSAN-2 | ||
// | ||
//[MSAN-0] compile-flags: -Zsanitizer=memory | ||
//[MSAN-1] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins=1 | ||
//[MSAN-2] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins | ||
|
||
#![crate_type="lib"] | ||
|
||
// MSAN-0-NOT: @__msan_track_origins | ||
// MSAN-1: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 1 | ||
// MSAN-2: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 2 | ||
// | ||
// MSAN-0-LABEL: define void @copy( | ||
// MSAN-1-LABEL: define void @copy( | ||
// MSAN-2-LABEL: define void @copy( | ||
#[no_mangle] | ||
pub fn copy(dst: &mut i32, src: &i32) { | ||
// MSAN-0-NOT: call i32 @__msan_chain_origin( | ||
// MSAN-1-NOT: call i32 @__msan_chain_origin( | ||
// MSAN-2: call i32 @__msan_chain_origin( | ||
*dst = *src; | ||
} |
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,34 @@ | ||
// Verifies that AddressSanitizer and MemorySanitizer | ||
// recovery mode can be enabled with -Zsanitizer-recover. | ||
// | ||
// needs-sanitizer-support | ||
// only-linux | ||
// only-x86_64 | ||
// revisions:ASAN ASAN-RECOVER MSAN MSAN-RECOVER | ||
// | ||
//[ASAN] compile-flags: -Zsanitizer=address | ||
//[ASAN-RECOVER] compile-flags: -Zsanitizer=address -Zsanitizer-recover=address | ||
//[MSAN] compile-flags: -Zsanitizer=memory | ||
//[MSAN-RECOVER] compile-flags: -Zsanitizer=memory -Zsanitizer-recover=memory | ||
|
||
#![crate_type="lib"] | ||
|
||
// ASAN-LABEL: define i32 @penguin( | ||
// ASAN-RECOVER-LABEL: define i32 @penguin( | ||
// MSAN-LABEL: define i32 @penguin( | ||
// MSAN-RECOVER-LABEL: define i32 @penguin( | ||
#[no_mangle] | ||
pub fn penguin(p: &mut i32) -> i32 { | ||
// ASAN: call void @__asan_report_load4(i64 %0) | ||
// ASAN: unreachable | ||
// | ||
// ASAN-RECOVER: call void @__asan_report_load4_noabort( | ||
// ASAN-RECOVER-NOT: unreachable | ||
// | ||
// MSAN: call void @__msan_warning_noreturn() | ||
// MSAN: unreachable | ||
// | ||
// MSAN-RECOVER: call void @__msan_warning() | ||
// MSAN-RECOVER-NOT: unreachable | ||
*p | ||
} |