This eagerly reports use of undef values when passed to noundef
parameters or returned from noundef functions.
This also decreases binary sizes under msan.
To go back to the previous behavior, pass -fno-sanitize-memory-param-retval.
Differential D134669
[clang][msan] Turn on -fsanitize-memory-param-retval by default aeubanks on Sep 26 2022, 12:56 PM. Authored by
Details This eagerly reports use of undef values when passed to noundef This also decreases binary sizes under msan. To go back to the previous behavior, pass -fno-sanitize-memory-param-retval.
Diff Detail
Event TimelineComment Actions hmm, looks like this breaks a bunch of msan tests with -DLLVM_ENABLE_RUNTIMES=compiler-rt and ninja && ninja check-runtimes MemorySanitizer-X86_64 :: Linux/swapcontext_annotation_reset.cpp MemorySanitizer-X86_64 :: bsearch.cpp MemorySanitizer-X86_64 :: chained_origin.cpp MemorySanitizer-X86_64 :: chained_origin_empty_stack.cpp MemorySanitizer-X86_64 :: chained_origin_memcpy.cpp MemorySanitizer-X86_64 :: chained_origin_memmove.cpp MemorySanitizer-X86_64 :: cxa_atexit.cpp MemorySanitizer-X86_64 :: insertvalue_origin.cpp MemorySanitizer-X86_64 :: no_sanitize_memory_prop.cpp MemorySanitizer-X86_64 :: noundef_analysis.cpp MemorySanitizer-X86_64 :: param_tls_limit.cpp MemorySanitizer-X86_64 :: qsort.cpp MemorySanitizer-X86_64 :: signal_stress_test.cpp MemorySanitizer-X86_64 :: unpoison_param.cpp MemorySanitizer-X86_64 :: vector_cvt.cpp SanitizerCommon-msan-x86_64-Linux :: get_module_and_offset_for_pc.cpp UBSan-MemorySanitizer-x86_64 :: TestCases/Misc/monitor.cpp UBSan-MemorySanitizer-x86_64 :: TestCases/TypeCheck/vptr.cpp Comment Actions LGTM. I was thinking about this recently as well. Comment Actions do you want the tests to all properly work with -fsanitize-memory-param-retval, or just pin them to -fno-sanitize-memory-param-retval if they're failing? Comment Actions diff --git a/clang/test/Driver/fsanitize-memory-param-retval.c b/clang/test/Driver/fsanitize-memory-param-retval.c index d82d20812186..79ade32178b6 100644 --- a/clang/test/Driver/fsanitize-memory-param-retval.c +++ b/clang/test/Driver/fsanitize-memory-param-retval.c @@ -1,14 +1,14 @@ -// RUN: %clang -target i386-gnu-linux %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s -// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s -// RUN: %clang -target aarch64-linux-gnu %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s -// RUN: %clang -target riscv32-linux-gnu %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s -// RUN: %clang -target riscv64-linux-gnu %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s -// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=kernel-memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s +// RUN: %clang -target i386-gnu-linux %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s +// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s +// RUN: %clang -target aarch64-linux-gnu %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s +// RUN: %clang -target riscv32-linux-gnu %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s +// RUN: %clang -target riscv64-linux-gnu %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s +// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=kernel-memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s -// CHECK: "-fsanitize-memory-param-retval" +// CHECK: "-fno-sanitize-memory-param-retval" -// RUN: %clang -target aarch64-linux-gnu -fsyntax-only %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck --check-prefix=11 %s -// 11: "-fsanitize-memory-param-retval" +// RUN: %clang -target aarch64-linux-gnu -fsyntax-only %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck --check-prefix=11 %s +// 11: "-fno-sanitize-memory-param-retval" -// RUN: not %clang -target x86_64-linux-gnu -fsyntax-only %s -fsanitize=memory -fsanitize-memory-param-retval=1 2>&1 | FileCheck --check-prefix=EXCESS %s -// EXCESS: error: unknown argument: '-fsanitize-memory-param-retval= +// RUN: not %clang -target x86_64-linux-gnu -fsyntax-only %s -fsanitize=memory -fno-sanitize-memory-param-retval=1 2>&1 | FileCheck --check-prefix=EXCESS %s +// EXCESS: error: unknown argument: '-fno-sanitize-memory-param-retval=
|
Probably I would mention that there is -fno-sanitize-memory-param-retval to disable it.
So one can use “-fsanitize=memory -fno-sanitize-memory-param-retval“ to unblock failed builds.