Visible to Intel only — GUID: GUID-25C595F0-B0C4-41B5-B994-1A1E38DC0AA5
Visible to Intel only — GUID: GUID-25C595F0-B0C4-41B5-B994-1A1E38DC0AA5
Dangling Lock
Occurs when a task does not release a lock before the task ends.
ID |
Code Location |
Description |
---|---|---|
1 |
Allocation site |
If present, represents the location and associated call stack when the lock was created. |
2 |
Lock owned |
If present, represents the location and its associated call stack when the lock was last acquired. |
3 |
Parallel site |
If present, represents the location and associated call stack of the site-begin annotation of the parallel site containing the task that acquired the lock. |
Example
void problem() { ANNOTATE_SITE_BEGIN(dangle_site1); // Parallel site ANNOTATE_TASK_BEGIN(task1); ANNOTATE_LOCK_ACQUIRE(&dangle); // Lock owned ANNOTATE_TASK_END(); // ... ANNOTATE_SITE_END(); }
In this example:
There is a parallel site that contains a task.
The lock is acquired in the task.
The lock is not released before the end of the task - the ANNOTATE_LOCK_RELEASE() annotation is missing.
Possible Correction Strategies
Make sure that an ANNOTATE_LOCK_RELEASE(address) annotation is executed on every flow path from an ANNOTATE_LOCK_ACQUIRE(address) annotation to the end of the task. If a code region has multiple exit flow paths, make sure the lock is released on all the paths.
Consider putting the lock-acquire and lock-release in the constructor and destructor of a static object, so that lock release happens automatically.
Consider putting a lock release in an exception handler if a the locked region might exit from an exception.