Asynchronously cancellable thread
Calling thread might be canceled in an unsafe state
Description
This defect occurs when you use pthread_setcanceltype with argument
PTHREAD_CANCEL_ASYNCHRONOUS to set the cancellability type of a
calling thread to asynchronous (or immediate). An asynchronously cancellable thread can
be canceled at any time, usually immediately upon receiving a cancellation
request.
Risk
The calling thread might be canceled in an unsafe state that could result in a resources leak, a deadlock, a data race, data corruption, or unpredictable behavior.
Fix
Remove the call to pthread_setcanceltype with argument
PTHREAD_CANCEL_ASYNCHRONOUS to use the default cancellability type
PTHREAD_CANCEL_DEFERRED instead. With the default cancellability type,
the thread defers cancellation requests until it calls a function that is a cancellation
point.
Examples
Result Information
| Group: Concurrency |
| Language: C | C++ |
| Default: Off |
Command-Line Syntax:
ASYNCHRONOUSLY_CANCELLABLE_THREAD
|
| Impact: Medium |
PQL Name:
std.defects.ASYNCHRONOUSLY_CANCELLABLE_THREAD
|
Version History
Introduced in R2020a
See Also
Topics
- Interpret Polyspace Bug Finder Results in Polyspace Platform User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Polyspace Results Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)