Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

并发性缺陷

与多任务处理代码相关的缺陷

这些检查项检测与多任务处理代码相关的问题,例如,多个任务对某个无保护的变量进行运算时的数据争用,或临界区涉及死锁的锁定缺陷。Polyspace 可以检测代码中的线程和临界区,您也可以手动在 Polyspace 配置中定义它们。

Polyspace 结果

全部展开

数据争用Multiple tasks perform unprotected nonatomic operations on shared variable
相邻位域的数据争用Multiple threads perform unprotected operations on adjacent bit fields of a shared data structure (自 R2020b 起)
对标准库函数调用的数据争用Multiple tasks make unprotected calls to thread-unsafe standard library function
保持锁时阻塞运算Task performs lengthy operation while holding a lock
死锁Call sequence to lock functions cause two tasks to block each other
销毁锁定互斥锁Task tries to destroy a mutex in the locked state
双锁Lock function is called twice in a task without an intermediate call to unlock function
双解锁Unlock function is called twice in a task without an intermediate call to lock function
缺失锁Unlock function without lock function
缺失解锁Lock function without unlock function
使用的多个互斥锁基于同一条件变量Threads using different mutexes when concurrently waiting on the same condition variable is undefined behavior (自 R2020a 起)
可异步取消的线程Calling thread might be cancelled in an unsafe state (自 R2020a 起)
连接已连接的线程或分离已分离的线程Thread that was previously joined or detached is joined or detached again (自 R2019b 起)
线程属性缺失初始化或重复初始化Duplicated initialization of thread attributes or noninitialized thread attribute used in functions that expect initialized attributes (自 R2019b 起)
多个线程等待同一条件变量Using 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 (自 R2020a 起)
在多线程程序中调用 signalProgram with multiple threads uses signal function
使用信号终止线程Uncaught signal kills entire process instead of specific thread
使用未定义的线程 IDThread ID from failed thread creation used in subsequent thread functions (自 R2019b 起)
自动或线程局部变量逃逸出线程Variable is passed from one thread to another without ensuring that variable stays alive through duration of latter thread (自 R2020a 起)
线程特有内存泄漏Dynamically allocated thread-specific memory not freed before end of thread
原子加载和存储序列是非原子的Variable accessible between load and store operations
在表达式中访问原子变量两次Variable can be modified between accesses
可虚假失败的函数未置于循环中Loop checks failure condition after possible spurious failure
可虚假唤醒的函数未置于循环中Loop checks wake-up condition after possible spurious wake-up

主题