Overview
Cache bug detection focuses on finding incorrect behavior in a processor's cache subsystem, especially memory errors that are difficult to anticipate with static unit-test suites. In the TestRIG work on randomized RISC-V CPU testing, cache bugs are described as a class of memory mistakes that can be discovered efficiently with targeted generators, while remaining notoriously difficult to find using static unit tests. [C1]
TestRIG approach
The cited TestRIG case used a generator that constructed addresses within the TestRIG memory range and emitted random loads and stores. This approach was applied after a cache issue escaped the existing unit-test suite. [C2]
The value of the approach comes from producing small, reproducible counterexamples. In the Flute cache case, the generator found the bug after 42 tests and 20 rounds of shrinking, reducing the failure to a short instruction sequence. [C3]
Flute cache bug example
The reported processor was Flute, described in the paper as a working in-order RV64G design. TestRIG exposed that its data cache was implemented as direct-mapped and 4 KiB, rather than the specified 2-way associative and 8 KiB cache. A parameter experiment confirmed that the 2-way cache configuration could not boot the operating system. [C4]
The shortened counterexample contained only three memory operations: two loads with a single store between them, all targeting overlapping addresses. The final reload diverged. The paper reports that the counterexample was found less than 10 seconds into the TestRIG run and that the fix was completed within an hour. [C5]
Why reduced counterexamples matter
The Flute bug had escaped the processor's development process and the RISC-V unit-test suite. The authors state that it was overwhelmingly difficult to debug from a full software trace, but trivial to resolve once TestRIG provided the reduced counterexample. [C6]
Related cache-observable behavior
The same evidence also shows TestRIG using assertions over hardware performance counters, including an L1 cache miss counter, to make cache-visible effects deterministic in a shrunken counterexample involving an illegal CHERI bounds operation. The paper reports that a capability value forwarded during a pipeline flush caused a cache fill that could lead to side-channel attacks. [C7]
Relationship to counterexample-driven development
The paper frames TestRIG's model-based testing as supporting counterexample-driven development: instead of waiting for broad software traces or hand-written unit tests, developers receive reduced stimuli that can expose both basic bugs and advanced interactions. QCVEngine is mentioned in this context as providing a tight cycle of reduced counterexamples for CHERI work on Ibex. [C8]