Main Content

Concurrency Defects

Defects related to multitasking code

These checkers detect issues related to multitasking code such as data races where multiple tasks operate on an unprotected variable, or locking defects where critical sections are involved in a deadlock. Polyspace can detect thread and critical sections in your code, or you can manually define those in the Polyspace configuration.

Polyspace Results

expand all

Data raceMultiple tasks perform unprotected nonatomic operations on shared variable
Data race on adjacent bit fieldsMultiple threads perform unprotected operations on adjacent bit fields of a shared data structure
Data race through standard library function callMultiple tasks make unprotected calls to thread-unsafe standard library function
DeadlockCall sequence to lock functions cause two tasks to block each other
Destruction of locked mutexTask tries to destroy a mutex in the locked state
Double lockLock function is called twice in a task without an intermediate call to unlock function
Double unlockUnlock function is called twice in a task without an intermediate call to lock function
Missing lockUnlock function without lock function
Missing unlockLock function without unlock function
Multiple mutexes used with same condition variableThreads using different mutexes when concurrently waiting on the same condition variable is undefined behavior
Blocking operation while holding lockTask performs lengthy operation while holding a lock
Asynchronously cancellable threadCalling thread might be cancelled in an unsafe state
Join or detach of a joined or detached threadThread that was previously joined or detached is joined or detached again
Missing or double initialization of thread attributeDuplicated initialization of thread attributes or noninitialized thread attribute used in functions that expect initialized attributes
Multiple threads waiting on same condition variableUsing cnd_signal to wake up one of the threads might result in indefinite blocking
Use of signal killing threadUncaught signal kills entire process instead of specific thread
Use of undefined thread IDThread ID from failed thread creation used in subsequent thread functions
Signal call in multithreaded programProgram with multiple threads uses signal function
Thread-specific memory leakDynamically allocated thread-specific memory not freed before end of thread
Automatic or thread local variable escaping from a threadVariable is passed from one thread to another without ensuring that variable stays alive through duration of latter thread
Atomic load and store sequence not atomicVariable accessible between load and store operations
Atomic variable accessed twice in an expressionVariable can be modified between accesses
Function that can spuriously fail not wrapped in loopLoop checks failure condition after possible spurious failure
Function that can spuriously wake up not wrapped in loopLoop checks wake-up condition after possible spurious wake-up

Topics