mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
36 lines
948 B
Plaintext
36 lines
948 B
Plaintext
/**
|
|
* @name A lock is held during a wait
|
|
* @description A lock is held during a call to System.Threading.Monitor.Wait(). This can lead to deadlocks and performance problems.
|
|
* @kind problem
|
|
* @problem.severity warning
|
|
* @precision high
|
|
* @id cs/locked-wait
|
|
* @tags quality
|
|
* reliability
|
|
* concurrency
|
|
* correctness
|
|
* external/cwe/cwe-662
|
|
* external/cwe/cwe-833
|
|
*/
|
|
|
|
import csharp
|
|
import Concurrency
|
|
|
|
from LockedBlock l, WaitStmt w, string lockedItem
|
|
where
|
|
l.getALockedStmt() = w and
|
|
(
|
|
exists(Variable v |
|
|
v = l.getLockVariable() and not v = w.getWaitVariable() and lockedItem = v.getName()
|
|
)
|
|
or
|
|
exists(Type t |
|
|
t = l.getLockTypeObject() and
|
|
not t = w.getWaitTypeObject() and
|
|
lockedItem = "typeof(" + t.getName() + ")"
|
|
)
|
|
or
|
|
l.isLockThis() and not w.isWaitThis() and lockedItem = "this"
|
|
)
|
|
select w, "'" + lockedItem + "' is locked during this wait."
|