Query module LockOrderInconsistency

name
Lock order inconsistency
description
Acquiring multiple locks in a different order may cause deadlock.
kind
problem
problem.severity
recommendation
precision
medium
id
java/lock-order-inconsistency
tags
security external/cwe/cwe-833

Imports

java

Provides all default Java QL imports.

Predicates

badMethodAccessLockOrder

A synchronized method outer accessed at outerAccess makes a synchronized method access in statement inner that is qualified by one of the parameters of outer, and there is another access to outer that may cause locking to be performed in a different order.

badReentrantLockOrder

In one situation, a ReentrantLock is obtained on one variable in first and then on another variable in second, but elsewhere, the lock order is reversed by first obtaining a lock on the latter variable in otherFirst.

badSynchronizedStmtLockOrder

In one situation, two synchronized statements outer and inner obtain locks on different variables in one order, and elsewhere, the lock order is reversed, starting with otherOuter.

inDifferentBranches

Holds if the specified method accesses occur on different branches of the same conditional statement inside an unsynchronized method.

inDifferentRunnables

Holds if the specified method accesses occur in different Runnable.run() methods, indicating that they may be invoked by different threads.

inRunnable

The method access ma occurs in method runnable, which is an implementation of Runnable.run().

qualifiedMethodAccess

The method access ma to method m is qualified by an access to variable vQual and has an access to variable vArg as the argument at index i.

Classes

LockVariable

A variable of type ReentrantLock.

Synched

A synchronized method or statement, or an expression statement containing an access to a synchronized method.