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:
Hao Xu
2026-06-07 15:42:49 +08:00
parent 27472a542c
commit 19b32a2e18

View File

@@ -19,6 +19,7 @@ struct CheckGlobalsImpl {
g_seeded_g_prng_zero = false;
g_used_system_time = false;
SetMockTime(0s);
MockableSteadyClock::ClearMockTime();
}
~CheckGlobalsImpl()
{