This vulnerability occurs when two or more threads within the same application access and manipulate a shared resource (like a variable, data structure, or file) without proper synchronization. Because the threads can execute in an unpredictable order, they can corrupt the resource's state, leading to crashes, incorrect calculations, or data loss.
Unlike race conditions between separate processes, this issue happens entirely within a single program's threads. It's a flaw in the program's internal logic where the developer assumed certain operations would complete in a specific sequence, but the operating system's thread scheduler can interleave them arbitrarily. Common triggers include checking a flag or counter in one thread while another is modifying it, or performing non-atomic 'read-modify-write' operations on shared data. To prevent this, developers must use proper synchronization primitives like mutexes, semaphores, or atomic operations. These tools create critical sections that ensure only one thread can access the shared resource at a time, guaranteeing predictable and valid states. Failing to implement synchronization correctly—or incorrectly assuming certain operations are thread-safe—leaves the application's behavior undefined and unreliable.
Impact: Alter Execution LogicUnexpected State
The main problem is that -- if a lock is overcome -- data could be altered in a bad state.
cjavaMedium