diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-08-26 08:10:10 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-08-26 08:10:12 +0200 |
commit | 84be9a89c1a49a7be5bc43d832b4cb9cbd09fce3 (patch) | |
tree | 3bd27299af3a6ff236ed84354a6d2c6b2a3d1a30 /src/test/fuzz | |
parent | f0461314815efda1a7cf6c499c6fe9277b1635cd (diff) | |
parent | fa2547fc52b90b4bbde250803df24d7f665383a7 (diff) |
Merge bitcoin/bitcoin#22755: fuzz: Avoid timeout in blockfilter fuzz target
fa2547fc52b90b4bbde250803df24d7f665383a7 fuzz: Avoid timeout in blockfilter fuzz target (MarcoFalke)
Pull request description:
Previously it would take 10 seconds to run this input, now it takes 10ms: [clusterfuzz-testcase-blockfilter-5022838196142080.log](https://github.com/bitcoin/bitcoin/files/7021883/clusterfuzz-testcase-blockfilter-5022838196142080.log)
The fix is moving the `MatchAny` out of the hot loop.
Also, to avoid unlimited runtime, cap the hot loop at 30k iterations.
ACKs for top commit:
GeneFerneau:
Approach ACK [fa2547f](https://github.com/bitcoin/bitcoin/pull/22755/commits/fa2547fc52b90b4bbde250803df24d7f665383a7)
Tree-SHA512: a04e7388856930ec81222da8f05b665a923fe9482aeb4c55c9be4561aa7320a0703dbbf8d438ae92854e877a8e3b46777a29c0b652b8f34c29c2142cc5d63ccb
Diffstat (limited to 'src/test/fuzz')
-rw-r--r-- | src/test/fuzz/blockfilter.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/test/fuzz/blockfilter.cpp b/src/test/fuzz/blockfilter.cpp index 7fa06085f8..96f049625d 100644 --- a/src/test/fuzz/blockfilter.cpp +++ b/src/test/fuzz/blockfilter.cpp @@ -36,9 +36,10 @@ FUZZ_TARGET(blockfilter) (void)gcs_filter.GetEncoded(); (void)gcs_filter.Match(ConsumeRandomLengthByteVector(fuzzed_data_provider)); GCSFilter::ElementSet element_set; - while (fuzzed_data_provider.ConsumeBool()) { + LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 30000) + { element_set.insert(ConsumeRandomLengthByteVector(fuzzed_data_provider)); - gcs_filter.MatchAny(element_set); } + gcs_filter.MatchAny(element_set); } } |