mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
Merge bitcoin/bitcoin#29012: fuzz: Avoid timeout in bitdeque
fad1903b8a
fuzz: Avoid timeout in bitdeque (MarcoFalke) Pull request description: Avoid timeouts such as https://github.com/bitcoin/bitcoin/issues/28812#issuecomment-1842914664 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: utACKfad1903b8a
dergoegge: utACKfad1903b8a
brunoerg: crACKfad1903b8a
Tree-SHA512: d3d83acb3e736b8fcaf5d17ce225ac82a9f9a2efea048512d2fed594ba6c76c25bae72eb0fab3276d4db37baec0752e5367cecfb18161301b921fed09693045e
This commit is contained in:
commit
2e8ec6b338
1 changed files with 16 additions and 16 deletions
|
@ -53,21 +53,11 @@ FUZZ_TARGET(bitdeque, .init = InitRandData)
|
|||
--initlen;
|
||||
}
|
||||
|
||||
LIMITED_WHILE(provider.remaining_bytes() > 0, 900)
|
||||
const auto iter_limit{maxlen > 6000 ? 90U : 900U};
|
||||
LIMITED_WHILE(provider.remaining_bytes() > 0, iter_limit)
|
||||
{
|
||||
{
|
||||
assert(deq.size() == bitdeq.size());
|
||||
auto it = deq.begin();
|
||||
auto bitit = bitdeq.begin();
|
||||
auto itend = deq.end();
|
||||
while (it != itend) {
|
||||
assert(*it == *bitit);
|
||||
++it;
|
||||
++bitit;
|
||||
}
|
||||
}
|
||||
|
||||
CallOneOf(provider,
|
||||
CallOneOf(
|
||||
provider,
|
||||
[&] {
|
||||
// constructor()
|
||||
deq = std::deque<bool>{};
|
||||
|
@ -535,7 +525,17 @@ FUZZ_TARGET(bitdeque, .init = InitRandData)
|
|||
assert(it == deq.begin() + before);
|
||||
assert(bitit == bitdeq.begin() + before);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
{
|
||||
assert(deq.size() == bitdeq.size());
|
||||
auto it = deq.begin();
|
||||
auto bitit = bitdeq.begin();
|
||||
auto itend = deq.end();
|
||||
while (it != itend) {
|
||||
assert(*it == *bitit);
|
||||
++it;
|
||||
++bitit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue