mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-07-23 14:48:55 +02:00
fuzz: reset the mockable steady clock between iterations
CheckGlobalsImpl's constructor runs at the start of every fuzz iteration and already resets the global RNG flags and the mockable NodeClock via SetMockTime(0s), but it never reset the mockable steady clock. A value written to g_mock_steady_time by one input therefore leaked into the next one. For example, FuzzedSock's constructor calls SetMockTime(INITIAL_MOCK_TIME) and never clears it, so the mocked steady time stays set for all subsequent iterations. Reset MockableSteadyClock symmetrically with NodeClock so each input starts from an unmocked steady clock. This also brings the steady clock under the same discipline as the system clock: a target that reads MockableSteadyClock::now() without first mocking it is now caught by the existing g_used_system_time check instead of silently reusing a leaked value.
This commit is contained in:
@@ -19,6 +19,7 @@ struct CheckGlobalsImpl {
|
||||
g_seeded_g_prng_zero = false;
|
||||
g_used_system_time = false;
|
||||
SetMockTime(0s);
|
||||
MockableSteadyClock::ClearMockTime();
|
||||
}
|
||||
~CheckGlobalsImpl()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user