[llvm] r293339 - [libFuzzer] make shmem more robust in the presence of signals
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 27 14:41:30 PST 2017
Author: kcc
Date: Fri Jan 27 16:41:30 2017
New Revision: 293339
URL: http://llvm.org/viewvc/llvm-project?rev=293339&view=rev
Log:
[libFuzzer] make shmem more robust in the presence of signals
Modified:
llvm/trunk/lib/Fuzzer/FuzzerShmemPosix.cpp
llvm/trunk/lib/Fuzzer/test/equivalence.test
Modified: llvm/trunk/lib/Fuzzer/FuzzerShmemPosix.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerShmemPosix.cpp?rev=293339&r1=293338&r2=293339&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerShmemPosix.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerShmemPosix.cpp Fri Jan 27 16:41:30 2017
@@ -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();
}
}
Modified: llvm/trunk/lib/Fuzzer/test/equivalence.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/equivalence.test?rev=293339&r1=293338&r2=293339&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/equivalence.test (original)
+++ llvm/trunk/lib/Fuzzer/test/equivalence.test Fri Jan 27 16:41:30 2017
@@ -4,3 +4,13 @@ RUN: not LLVMFuzzer-EquivalenceBTest -us
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
More information about the llvm-commits
mailing list