Infer flagged a “Lock Consistency Violation.” The method animation::fps()
performs reads and writes to the internal frame-rate variable without proper thread
synchronization.
I wrote a multi-threaded PoC that rapidly alternated the frame rate
between 30 and 60 FPS from background threads. This race condition corrupted the
internal timing logic, forcing the render loop into a busy-wait state that consumed
100% of the host’s CPU core, leading to system lag and thermal strain.
race_demo.cpp
Suggestion to Fix: Wrap the getter and setter of the frame-rate variable inside
a std::lock guardstd::mutex. For a more performant fix, change the type of
the fps member variable to std::atomic<std::size t>.
Infer flagged a “Lock Consistency Violation.” The method animation::fps()
performs reads and writes to the internal frame-rate variable without proper thread
synchronization.
I wrote a multi-threaded PoC that rapidly alternated the frame rate
between 30 and 60 FPS from background threads. This race condition corrupted the
internal timing logic, forcing the render loop into a busy-wait state that consumed
100% of the host’s CPU core, leading to system lag and thermal strain.
race_demo.cpp
Suggestion to Fix: Wrap the getter and setter of the frame-rate variable inside
a std::lock guardstd::mutex. For a more performant fix, change the type of
the fps member variable to std::atomic<std::size t>.