Skip to content

Commit 428beba

Browse files
committed
[libFuzzer] Fix value-profile-load test.
The behavior of the CrossOver mutator has changed with bb54bcf. This seems to affect the value-profile-load test on Darwin. This patch provides a wider margin for determining success of the value-profile-load test, by testing the targeted functionality (i.e., GEP index value profile) more directly and faster. To this end, LoadTest.cpp now uses a narrower condition (Size != 8) for initial pruning of inputs, effectively preventing libFuzzer from generating inputs longer than necessary and spending time on mutating such long inputs in the corpus - a functionality not meant to be tested by this specific test. Previously, on x86/Linux, it required 6,597,751 execs with -use_value_profile=1 and 19,605,575 execs with -use_value_profile=0 to hit the crash. With this patch, the test passes with 174,493 execs, providing a wider margin from the given trials of 10,000,000. Note that, without the value profile (i.e., -use_value_profile=0), the test wouldn't pass as it still requires 19,605,575 execs to hit the crash. Differential Revision: https://reviews.llvm.org/D86247
1 parent 4deda57 commit 428beba

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler-rt/test/fuzzer/LoadTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ const int kArraySize = 1234567;
1414
int array[kArraySize];
1515

1616
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
17-
if (Size < 8) return 0;
17+
if (Size != 8)
18+
return 0;
1819
uint64_t a = 0;
1920
memcpy(&a, Data, 8);
2021
Sink = array[a % (kArraySize + 1)];
2122
return 0;
2223
}
23-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
CHECK: AddressSanitizer: global-buffer-overflow
22
RUN: %cpp_compiler %S/LoadTest.cpp -fsanitize-coverage=trace-gep -o %t-LoadTest
3-
RUN: not %run %t-LoadTest -seed=2 -use_cmp=0 -use_value_profile=1 -runs=20000000 2>&1 | FileCheck %s
3+
RUN: not %run %t-LoadTest -seed=2 -use_cmp=0 -use_value_profile=1 -runs=10000000 2>&1 | FileCheck %s

0 commit comments

Comments
 (0)