summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2017-01-27 22:41:30 +0000
committerKostya Serebryany <kcc@google.com>2017-01-27 22:41:30 +0000
commit6d58dbb62ffb2a1d36f15848dd7b3fb588c18bcb (patch)
tree9c3647e76f30ca3b53fefeedb4d81108425708b0 /llvm/lib/Fuzzer
parent33b01e9cfec36c9b2349e30872104309bc71bf50 (diff)
downloadbcm5719-llvm-6d58dbb62ffb2a1d36f15848dd7b3fb588c18bcb.tar.gz
bcm5719-llvm-6d58dbb62ffb2a1d36f15848dd7b3fb588c18bcb.zip
[libFuzzer] make shmem more robust in the presence of signals
llvm-svn: 293339
Diffstat (limited to 'llvm/lib/Fuzzer')
-rw-r--r--llvm/lib/Fuzzer/FuzzerShmemPosix.cpp10
-rw-r--r--llvm/lib/Fuzzer/test/equivalence.test10
2 files changed, 17 insertions, 3 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerShmemPosix.cpp b/llvm/lib/Fuzzer/FuzzerShmemPosix.cpp
index 820d64d07c1..d5f4aabc426 100644
--- a/llvm/lib/Fuzzer/FuzzerShmemPosix.cpp
+++ b/llvm/lib/Fuzzer/FuzzerShmemPosix.cpp
@@ -86,9 +86,13 @@ void SharedMemoryRegion::Post(int Idx) {
void SharedMemoryRegion::Wait(int Idx) {
assert(Idx == 0 || Idx == 1);
- if (sem_wait((sem_t*)Semaphore[Idx])) {
- Printf("ERROR: sem_wait failed\n");
- exit(1);
+ for (int i = 0; i < 10 && sem_wait((sem_t*)Semaphore[Idx]); i++) {
+ // sem_wait may fail if interrupted by a signal.
+ sleep(i);
+ if (i)
+ Printf("%s: sem_wait[%d] failed %s\n", i < 9 ? "WARNING" : "ERROR", i,
+ strerror(errno));
+ if (i == 9) abort();
}
}
diff --git a/llvm/lib/Fuzzer/test/equivalence.test b/llvm/lib/Fuzzer/test/equivalence.test
index 8c8b9ba1554..6c9d87888e0 100644
--- a/llvm/lib/Fuzzer/test/equivalence.test
+++ b/llvm/lib/Fuzzer/test/equivalence.test
@@ -4,3 +4,13 @@ RUN: not LLVMFuzzer-EquivalenceBTest -use_equivalence_server=EQUIV_TEST 2>&1 | F
CHECK: ERROR: libFuzzer: equivalence-mismatch. Sizes: {{.*}}; offset 2
CHECK: SUMMARY: libFuzzer: equivalence-mismatch
RUN: kill -9 $APID
+
+
+# Run EquivalenceATest against itself with a small timeout
+# to stress the signal handling and ensure that shmem doesn't mind
+# the signals.
+
+RUN: LLVMFuzzer-EquivalenceATest -timeout=1 -run_equivalence_server=EQUIV_TEST & export APID=$!
+RUN: sleep 3
+RUN: LLVMFuzzer-EquivalenceATest -timeout=1 -use_equivalence_server=EQUIV_TEST -runs=500000 2>&1
+RUN: kill -9 $APID
OpenPOWER on IntegriCloud