[PATCH] D33522: [libFuzzer] Don't replace custom signal handlers.
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 24 18:43:23 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303828: [libFuzzer] Don't replace custom signal handlers. (authored by vitalybuka).
Changed prior to commit:
https://reviews.llvm.org/D33522?vs=100194&id=100195#toc
Repository:
rL LLVM
https://reviews.llvm.org/D33522
Files:
llvm/trunk/lib/Fuzzer/FuzzerUtilPosix.cpp
llvm/trunk/lib/Fuzzer/test/fuzzer-segv.test
Index: llvm/trunk/lib/Fuzzer/FuzzerUtilPosix.cpp
===================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerUtilPosix.cpp
+++ llvm/trunk/lib/Fuzzer/FuzzerUtilPosix.cpp
@@ -47,8 +47,21 @@
static void SetSigaction(int signum,
void (*callback)(int, siginfo_t *, void *)) {
- struct sigaction sigact;
- memset(&sigact, 0, sizeof(sigact));
+ struct sigaction sigact = {};
+ if (sigaction(signum, nullptr, &sigact)) {
+ Printf("libFuzzer: sigaction failed with %d\n", errno);
+ exit(1);
+ }
+ if (sigact.sa_flags & SA_SIGINFO) {
+ if (sigact.sa_sigaction)
+ return;
+ } else {
+ if (sigact.sa_handler != SIG_DFL && sigact.sa_handler != SIG_IGN &&
+ sigact.sa_handler != SIG_ERR)
+ return;
+ }
+
+ sigact = {};
sigact.sa_sigaction = callback;
if (sigaction(signum, &sigact, 0)) {
Printf("libFuzzer: sigaction failed with %d\n", errno);
Index: llvm/trunk/lib/Fuzzer/test/fuzzer-segv.test
===================================================================
--- llvm/trunk/lib/Fuzzer/test/fuzzer-segv.test
+++ llvm/trunk/lib/Fuzzer/test/fuzzer-segv.test
@@ -3,3 +3,5 @@
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 LLVMFuzzer-NullDerefTest 2>&1 | FileCheck %s --check-prefix=LIBFUZZER_ASAN_SEGV_HANDLER
+LIBFUZZER_ASAN_SEGV_HANDLER: ERROR: AddressSanitizer: {{SEGV|access-violation}} on unknown address
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33522.100195.patch
Type: text/x-patch
Size: 1532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170525/f463f8bd/attachment.bin>
More information about the llvm-commits
mailing list