[PATCH] D57465: [libFuzzer] Set default sanitizer options in fuzzer tests
Julian Lettner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 30 17:04:28 PST 2019
yln updated this revision to Diff 184415.
yln added a comment.
Update patch.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57465/new/
https://reviews.llvm.org/D57465
Files:
compiler-rt/lib/fuzzer/FuzzerLoop.cpp
compiler-rt/test/fuzzer/fuzzer-segv.test
compiler-rt/test/fuzzer/large.test
compiler-rt/test/fuzzer/lit.cfg
compiler-rt/test/fuzzer/minimize_two_crashes.test
compiler-rt/test/fuzzer/strncmp-oob.test
Index: compiler-rt/test/fuzzer/strncmp-oob.test
===================================================================
--- compiler-rt/test/fuzzer/strncmp-oob.test
+++ compiler-rt/test/fuzzer/strncmp-oob.test
@@ -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
Index: compiler-rt/test/fuzzer/minimize_two_crashes.test
===================================================================
--- compiler-rt/test/fuzzer/minimize_two_crashes.test
+++ compiler-rt/test/fuzzer/minimize_two_crashes.test
@@ -6,7 +6,7 @@
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
Index: compiler-rt/test/fuzzer/lit.cfg
===================================================================
--- compiler-rt/test/fuzzer/lit.cfg
+++ compiler-rt/test/fuzzer/lit.cfg
@@ -119,6 +119,13 @@
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"
Index: compiler-rt/test/fuzzer/large.test
===================================================================
--- compiler-rt/test/fuzzer/large.test
+++ compiler-rt/test/fuzzer/large.test
@@ -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
Index: compiler-rt/test/fuzzer/fuzzer-segv.test
===================================================================
--- compiler-rt/test/fuzzer/fuzzer-segv.test
+++ compiler-rt/test/fuzzer/fuzzer-segv.test
@@ -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
Index: compiler-rt/lib/fuzzer/FuzzerLoop.cpp
===================================================================
--- compiler-rt/lib/fuzzer/FuzzerLoop.cpp
+++ compiler-rt/lib/fuzzer/FuzzerLoop.cpp
@@ -232,8 +232,9 @@
}
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"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57465.184415.patch
Type: text/x-patch
Size: 4440 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190131/ece1639d/attachment.bin>
More information about the llvm-commits
mailing list