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

Asynchronously cancellable threadCalling thread might be cancelled in an unsafe state
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
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
Blocking operation while holding lockTask performs lengthy operation while holding a lock
Data raceMultiple tasks perform unprotected nonatomic operations on shared variable
Data race including atomic operationsMultiple tasks perform unprotected 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
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
Join or detach of a joined or detached threadThread that was previously joined or detached is joined or detached again
Missing lockUnlock function without lock function
Missing or double initialization of thread attributeDuplicated initialization of thread attributes or noninitialized thread attribute used in functions that expect initialized attributes
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
Multiple threads waiting on same condition variableUsing cnd_signal to wake up one of the threads might result in indefinite blocking
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
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


Bug Finder Defect Groups

The Bug Finder defect checkers are classified into groups such as data flow, concurrency, numerical, and so on.

Analyze Multitasking Programs in Polyspace

Detect data races or deadlocks with Bug Finder, or see a comprehensive analysis of shared variable usage with Code Prover.

Protections for Shared Variables in Multitasking Code

Protect shared variables by using critical section, temporal exclusion, priorities, or interrupt disabling.