[compiler-rt] r352711 - [libFuzzer] Set default sanitizer options in fuzzer tests
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 30 17:24:01 PST 2019
Author: yln
Date: Wed Jan 30 17:24:01 2019
New Revision: 352711
URL: http://llvm.org/viewvc/llvm-project?rev=352711&view=rev
Log:
[libFuzzer] Set default sanitizer options in fuzzer tests
Summary:
Set default `ASAN_OPTIONS` when running libFuzzer tests. This allows us
to remove special casing in code for Darwin where we usually pass
`abort_on_error=0` to override platform defaults for tests.
A previous commit changed the code to make the tests pass:
https://github.com/llvm/llvm-project/commit/7764a04af007eca68eafcf5caaea560ed05e35a9
Adapted a few tests to use `%env_asan_opts=` instead of directly setting
the environment variable.
rdar://problem/47515276
Reviewers: kcc, george.karpenkov
Differential Revision: https://reviews.llvm.org/D57465
Modified:
compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp
compiler-rt/trunk/test/fuzzer/fuzzer-segv.test
compiler-rt/trunk/test/fuzzer/large.test
compiler-rt/trunk/test/fuzzer/lit.cfg
compiler-rt/trunk/test/fuzzer/minimize_two_crashes.test
compiler-rt/trunk/test/fuzzer/strncmp-oob.test
Modified: compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp?rev=352711&r1=352710&r2=352711&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp Wed Jan 30 17:24:01 2019
@@ -232,8 +232,9 @@ void Fuzzer::StaticFileSizeExceedCallbac
}
void Fuzzer::CrashCallback() {
- if (EF->__sanitizer_acquire_crash_state)
- EF->__sanitizer_acquire_crash_state();
+ if (EF->__sanitizer_acquire_crash_state &&
+ !EF->__sanitizer_acquire_crash_state())
+ return;
Printf("==%lu== ERROR: libFuzzer: deadly signal\n", GetPid());
PrintStackTrace();
Printf("NOTE: libFuzzer has rudimentary signal handlers.\n"
Modified: compiler-rt/trunk/test/fuzzer/fuzzer-segv.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/fuzzer-segv.test?rev=352711&r1=352710&r2=352711&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/fuzzer-segv.test (original)
+++ compiler-rt/trunk/test/fuzzer/fuzzer-segv.test Wed Jan 30 17:24:01 2019
@@ -1,8 +1,8 @@
RUN: %cpp_compiler %S/NullDerefTest.cpp -o %t-NullDerefTest
-RUN: env ASAN_OPTIONS=handle_segv=0 not %run %t-NullDerefTest 2>&1 | FileCheck %s --check-prefix=LIBFUZZER_OWN_SEGV_HANDLER
+RUN: %env_asan_opts=handle_segv=0 not %run %t-NullDerefTest 2>&1 | FileCheck %s --check-prefix=LIBFUZZER_OWN_SEGV_HANDLER
LIBFUZZER_OWN_SEGV_HANDLER: == ERROR: libFuzzer: deadly signal
LIBFUZZER_OWN_SEGV_HANDLER: SUMMARY: libFuzzer: deadly signal
LIBFUZZER_OWN_SEGV_HANDLER: Test unit written to ./crash-
-RUN: env ASAN_OPTIONS=handle_segv=1 not %run %t-NullDerefTest 2>&1 | FileCheck %s --check-prefix=LIBFUZZER_ASAN_SEGV_HANDLER
+RUN: %env_asan_opts=handle_segv=1 not %run %t-NullDerefTest 2>&1 | FileCheck %s --check-prefix=LIBFUZZER_ASAN_SEGV_HANDLER
LIBFUZZER_ASAN_SEGV_HANDLER: ERROR: AddressSanitizer: {{SEGV|access-violation}} on unknown address
Modified: compiler-rt/trunk/test/fuzzer/large.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/large.test?rev=352711&r1=352710&r2=352711&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/large.test (original)
+++ compiler-rt/trunk/test/fuzzer/large.test Wed Jan 30 17:24:01 2019
@@ -1,6 +1,6 @@
REQUIRES: linux
RUN: %cpp_compiler %S/LargeTest.cpp -o %t-LargeTest
RUN: %run %t-LargeTest -runs=10000
-RUN: ASAN_OPTIONS=handle_segv=0 %run %t-LargeTest -runs=10000 -lazy_counters=1 2>&1 | FileCheck %s
+RUN: %env_asan_opts=handle_segv=0 %run %t-LargeTest -runs=10000 -lazy_counters=1 2>&1 | FileCheck %s
CHECK: pages of counters where protected; libFuzzer's SEGV handler must be installed
Modified: compiler-rt/trunk/test/fuzzer/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/lit.cfg?rev=352711&r1=352710&r2=352711&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/lit.cfg (original)
+++ compiler-rt/trunk/test/fuzzer/lit.cfg Wed Jan 30 17:24:01 2019
@@ -119,6 +119,13 @@ config.substitutions.append(('%msan_comp
generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True, msan_enabled=True)
))
+default_asan_opts_str = ':'.join(config.default_sanitizer_opts)
+if default_asan_opts_str:
+ config.environment['ASAN_OPTIONS'] = default_asan_opts_str
+ default_asan_opts_str += ':'
+config.substitutions.append(('%env_asan_opts=',
+ 'env ASAN_OPTIONS=' + default_asan_opts_str))
+
if config.host_os == 'Darwin':
if config.target_arch in ["x86_64", "x86_64h"]:
config.parallelism_group = "darwin-64bit-sanitizer"
Modified: compiler-rt/trunk/test/fuzzer/minimize_two_crashes.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/minimize_two_crashes.test?rev=352711&r1=352710&r2=352711&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/minimize_two_crashes.test (original)
+++ compiler-rt/trunk/test/fuzzer/minimize_two_crashes.test Wed Jan 30 17:24:01 2019
@@ -6,7 +6,7 @@ RUN: %cpp_compiler -O0 %S/TwoDifferentBu
RUN: rm -rf %t && mkdir %t
RUN: echo H12345678901234667888090 > %t/long_crash
-RUN: env ASAN_OPTIONS=dedup_token_length=3 %run %t-TwoDifferentBugsTest -seed=1 -minimize_crash=1 %t/long_crash -exact_artifact_path=%t/result 2>&1 | FileCheck %s
+RUN: %env_asan_opts=dedup_token_length=3 %run %t-TwoDifferentBugsTest -seed=1 -minimize_crash=1 %t/long_crash -exact_artifact_path=%t/result 2>&1 | FileCheck %s
CHECK: DedupToken1: DEDUP_TOKEN: Bar
CHECK: DedupToken2: DEDUP_TOKEN: Bar
Modified: compiler-rt/trunk/test/fuzzer/strncmp-oob.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/strncmp-oob.test?rev=352711&r1=352710&r2=352711&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/strncmp-oob.test (original)
+++ compiler-rt/trunk/test/fuzzer/strncmp-oob.test Wed Jan 30 17:24:01 2019
@@ -1,6 +1,6 @@
RUN: %cpp_compiler %S/StrncmpOOBTest.cpp -o %t-StrncmpOOBTest
-RUN: env ASAN_OPTIONS=strict_string_checks=1 not %run %t-StrncmpOOBTest -seed=1 -runs=1000000 2>&1 | FileCheck %s --check-prefix=STRNCMP
+RUN: %env_asan_opts=strict_string_checks=1 not %run %t-StrncmpOOBTest -seed=1 -runs=1000000 2>&1 | FileCheck %s --check-prefix=STRNCMP
STRNCMP: AddressSanitizer: heap-buffer-overflow
STRNCMP-NOT: __sanitizer_weak_hook_strncmp
STRNCMP: in LLVMFuzzerTestOneInput
More information about the llvm-commits
mailing list