1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00

[libFuzzer] make shmem more robust in the presence of signals

llvm-svn: 293339
This commit is contained in:
Kostya Serebryany 2017-01-27 22:41:30 +00:00
parent ead6d1c1e8
commit 41936ee2a4
2 changed files with 17 additions and 3 deletions

View File

@ -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();
}
}

View File

@ -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