Skip to content

Commit 2e8ec6b

Browse files
committed
Merge bitcoin/bitcoin#29012: fuzz: Avoid timeout in bitdeque
fad1903 fuzz: Avoid timeout in bitdeque (MarcoFalke) Pull request description: Avoid timeouts such as bitcoin/bitcoin#28812 (comment) This is done by: * Limiting the maximum number of iterations if the maximum size of the container is "large" (see the magic numbers in the code). * Check the equality only once. This should be fine, because if a crash were to happen in the equality check, but the crash doesn't happen if further iterations were run, the fuzz engine should eventually find the crash by truncating the fuzz input. ACKs for top commit: sipa: utACK fad1903 dergoegge: utACK fad1903 brunoerg: crACK fad1903 Tree-SHA512: d3d83acb3e736b8fcaf5d17ce225ac82a9f9a2efea048512d2fed594ba6c76c25bae72eb0fab3276d4db37baec0752e5367cecfb18161301b921fed09693045e
2 parents c46cc8d + fad1903 commit 2e8ec6b

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/test/fuzz/bitdeque.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,11 @@ FUZZ_TARGET(bitdeque, .init = InitRandData)
5353
--initlen;
5454
}
5555

56-
LIMITED_WHILE(provider.remaining_bytes() > 0, 900)
56+
const auto iter_limit{maxlen > 6000 ? 90U : 900U};
57+
LIMITED_WHILE(provider.remaining_bytes() > 0, iter_limit)
5758
{
58-
{
59-
assert(deq.size() == bitdeq.size());
60-
auto it = deq.begin();
61-
auto bitit = bitdeq.begin();
62-
auto itend = deq.end();
63-
while (it != itend) {
64-
assert(*it == *bitit);
65-
++it;
66-
++bitit;
67-
}
68-
}
69-
70-
CallOneOf(provider,
59+
CallOneOf(
60+
provider,
7161
[&] {
7262
// constructor()
7363
deq = std::deque<bool>{};
@@ -535,7 +525,17 @@ FUZZ_TARGET(bitdeque, .init = InitRandData)
535525
assert(it == deq.begin() + before);
536526
assert(bitit == bitdeq.begin() + before);
537527
}
538-
}
539-
);
528+
});
529+
}
530+
{
531+
assert(deq.size() == bitdeq.size());
532+
auto it = deq.begin();
533+
auto bitit = bitdeq.begin();
534+
auto itend = deq.end();
535+
while (it != itend) {
536+
assert(*it == *bitit);
537+
++it;
538+
++bitit;
539+
}
540540
}
541541
}

0 commit comments

Comments
 (0)