Skip to content

[Bug] Unsynchronized Race Condition causes 100% CPU Overload in animation::fps() #735

Description

@CatalinChifor

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>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions