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 (Since R2020b)
Data race through standard library function callMultiple tasks make unprotected calls to thread-unsafe standard library function
Blocking operation while holding lockTask performs lengthy operation while holding a lock
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 (Since R2020a)
Asynchronously cancellable threadCalling thread might be cancelled in an unsafe state (Since R2020a)
Join or detach of a joined or detached threadThread that was previously joined or detached is joined or detached again (Since R2019b)
Missing or double initialization of thread attributeDuplicated initialization of thread attributes or noninitialized thread attribute used in functions that expect initialized attributes (Since R2019b)
Multiple threads waiting on same condition variableUsing cnd_signal or std::condition_variable::notify_one() to notify one of the threads waiting for the same condition variable might result in indefinite blocking (Since R2020a)
Signal call in multithreaded programProgram with multiple threads uses signal function
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 (Since R2019b)
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 (Since R2020a)
Thread-specific memory leakDynamically allocated thread-specific memory not freed before end of 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