[compiler-rt] 8831e34 - Revert "[libFuzzer] Fix arguments of InsertPartOf/CopyPartOf calls in CrossOver mutator."
Azharuddin Mohammed via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 21 10:01:08 PDT 2020
Author: Azharuddin Mohammed
Date: 2020-08-21T09:58:50-07:00
New Revision: 8831e34771fec4dfbe62a6e31d9bc9419a3b93c3
URL: https://github.com/llvm/llvm-project/commit/8831e34771fec4dfbe62a6e31d9bc9419a3b93c3
DIFF: https://github.com/llvm/llvm-project/commit/8831e34771fec4dfbe62a6e31d9bc9419a3b93c3.diff
LOG: Revert "[libFuzzer] Fix arguments of InsertPartOf/CopyPartOf calls in CrossOver mutator."
This reverts commit bb54bcf84970c04c9748004f3a4cf59b0c1832a7.
It is causing the value-profile-load.test test to fail on macOS.
Added:
Modified:
compiler-rt/lib/fuzzer/FuzzerMutate.cpp
compiler-rt/test/fuzzer/CrossOverTest.cpp
compiler-rt/test/fuzzer/cross_over.test
Removed:
compiler-rt/test/fuzzer/cross_over_copy.test
compiler-rt/test/fuzzer/cross_over_insert.test
################################################################################
diff --git a/compiler-rt/lib/fuzzer/FuzzerMutate.cpp b/compiler-rt/lib/fuzzer/FuzzerMutate.cpp
index df9ada45bb03..29541eac5dc6 100644
--- a/compiler-rt/lib/fuzzer/FuzzerMutate.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerMutate.cpp
@@ -425,26 +425,26 @@ size_t MutationDispatcher::Mutate_CrossOver(uint8_t *Data, size_t Size,
if (!CrossOverWith) return 0;
const Unit &O = *CrossOverWith;
if (O.empty()) return 0;
+ MutateInPlaceHere.resize(MaxSize);
+ auto &U = MutateInPlaceHere;
size_t NewSize = 0;
switch(Rand(3)) {
case 0:
- MutateInPlaceHere.resize(MaxSize);
- NewSize = CrossOver(Data, Size, O.data(), O.size(),
- MutateInPlaceHere.data(), MaxSize);
- memcpy(Data, MutateInPlaceHere.data(), NewSize);
+ NewSize = CrossOver(Data, Size, O.data(), O.size(), U.data(), U.size());
break;
case 1:
- NewSize = InsertPartOf(O.data(), O.size(), Data, Size, MaxSize);
+ NewSize = InsertPartOf(O.data(), O.size(), U.data(), U.size(), MaxSize);
if (!NewSize)
- NewSize = CopyPartOf(O.data(), O.size(), Data, Size);
+ NewSize = CopyPartOf(O.data(), O.size(), U.data(), U.size());
break;
case 2:
- NewSize = CopyPartOf(O.data(), O.size(), Data, Size);
+ NewSize = CopyPartOf(O.data(), O.size(), U.data(), U.size());
break;
default: assert(0);
}
assert(NewSize > 0 && "CrossOver returned empty unit");
assert(NewSize <= MaxSize && "CrossOver returned overisized unit");
+ memcpy(Data, U.data(), NewSize);
return NewSize;
}
diff --git a/compiler-rt/test/fuzzer/CrossOverTest.cpp b/compiler-rt/test/fuzzer/CrossOverTest.cpp
index b4506f665dc7..a7643570a92b 100644
--- a/compiler-rt/test/fuzzer/CrossOverTest.cpp
+++ b/compiler-rt/test/fuzzer/CrossOverTest.cpp
@@ -4,11 +4,10 @@
// Test for a fuzzer. The fuzzer must find the string
// ABCDEFGHIJ
-// We use it as a test for each of CrossOver functionalities
-// by passing the following sets of two inputs to it:
-// {ABCDE00000, ZZZZZFGHIJ}
-// {ABCDEHIJ, ZFG} to specifically test InsertPartOf
-// {ABCDE00HIJ, ZFG} to specifically test CopyPartOf
+// We use it as a test for CrossOver functionality
+// by passing two inputs to it:
+// ABCDE00000
+// ZZZZZFGHIJ
//
#include <assert.h>
#include <cstddef>
@@ -43,11 +42,13 @@ static const uint32_t ExpectedHash = 0xe1677acb;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
// fprintf(stderr, "ExpectedHash: %x\n", ExpectedHash);
- if (Size == 10 && ExpectedHash == simple_hash(Data, Size))
- *NullPtr = 0;
+ if (Size != 10) return 0;
if (*Data == 'A')
Sink++;
if (*Data == 'Z')
Sink--;
+ if (ExpectedHash == simple_hash(Data, Size))
+ *NullPtr = 0;
return 0;
}
+
diff --git a/compiler-rt/test/fuzzer/cross_over.test b/compiler-rt/test/fuzzer/cross_over.test
index 64e06e8cd366..058b5eb2c85c 100644
--- a/compiler-rt/test/fuzzer/cross_over.test
+++ b/compiler-rt/test/fuzzer/cross_over.test
@@ -12,7 +12,7 @@ RUN: echo -n ABCDE00000 > %t-corpus/A
RUN: echo -n ZZZZZFGHIJ > %t-corpus/B
-RUN: not %run %t-CrossOverTest -max_len=10 -reduce_inputs=0 -seed=1 -runs=10000000 %t-corpus
+RUN: not %run %t-CrossOverTest -max_len=10 -seed=1 -runs=10000000 %t-corpus
# Test the same thing but using -seed_inputs instead of passing the corpus dir.
-RUN: not %run %t-CrossOverTest -max_len=10 -reduce_inputs=0 -seed=1 -runs=10000000 -seed_inputs=%t-corpus/A,%t-corpus/B
+RUN: not %run %t-CrossOverTest -max_len=10 -seed=1 -runs=10000000 -seed_inputs=%t-corpus/A,%t-corpus/B
diff --git a/compiler-rt/test/fuzzer/cross_over_copy.test b/compiler-rt/test/fuzzer/cross_over_copy.test
deleted file mode 100644
index 24b2f9b3b113..000000000000
--- a/compiler-rt/test/fuzzer/cross_over_copy.test
+++ /dev/null
@@ -1,20 +0,0 @@
-# Tests CrossOver CopyPartOf.
-# We want to make sure that the test can find the input
-# ABCDEFGHIJ when given two other inputs in the seed corpus:
-# ABCDE00HIJ and
-# (Z) FG
-#
-RUN: %cpp_compiler %S/CrossOverTest.cpp -o %t-CrossOverTest
-
-RUN: rm -rf %t-corpus
-RUN: mkdir %t-corpus
-RUN: echo -n ABCDE00HIJ > %t-corpus/A
-RUN: echo -n ZFG > %t-corpus/B
-
-
-RUN: not %run %t-CrossOverTest -mutate_depth=1 -max_len=1024 -reduce_inputs=0 -seed=1 -runs=10000000 %t-corpus 2>&1 | FileCheck %s
-
-# Test the same thing but using -seed_inputs instead of passing the corpus dir.
-RUN: not %run %t-CrossOverTest -mutate_depth=1 -max_len=1024 -reduce_inputs=0 -seed=1 -runs=10000000 -seed_inputs=%t-corpus/A,%t-corpus/B 2>&1 | FileCheck %s
-
-CHECK: MS: 1 CrossOver-
diff --git a/compiler-rt/test/fuzzer/cross_over_insert.test b/compiler-rt/test/fuzzer/cross_over_insert.test
deleted file mode 100644
index cb7d4fab81ef..000000000000
--- a/compiler-rt/test/fuzzer/cross_over_insert.test
+++ /dev/null
@@ -1,20 +0,0 @@
-# Tests CrossOver InsertPartOf.
-# We want to make sure that the test can find the input
-# ABCDEFGHIJ when given two other inputs in the seed corpus:
-# ABCDE HIJ and
-# (Z) FG
-#
-RUN: %cpp_compiler %S/CrossOverTest.cpp -o %t-CrossOverTest
-
-RUN: rm -rf %t-corpus
-RUN: mkdir %t-corpus
-RUN: echo -n ABCDEHIJ > %t-corpus/A
-RUN: echo -n ZFG > %t-corpus/B
-
-
-RUN: not %run %t-CrossOverTest -mutate_depth=1 -max_len=1024 -reduce_inputs=0 -seed=1 -runs=10000000 %t-corpus 2>&1 | FileCheck %s
-
-# Test the same thing but using -seed_inputs instead of passing the corpus dir.
-RUN: not %run %t-CrossOverTest -mutate_depth=1 -max_len=1024 -reduce_inputs=0 -seed=1 -runs=10000000 -seed_inputs=%t-corpus/A,%t-corpus/B 2>&1 | FileCheck %s
-
-CHECK: MS: 1 CrossOver-
More information about the llvm-commits
mailing list