Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

JD.LOCK.NOTIFY

JD.LOCK.NOTIFY occurs when the code calls notify() or notifyAll() while two locks are held.

Vulnerability and risk

The code calls notify() or notifyAll() while two locks are held. If this notification is intended to wake up a wait() that is holding the same locks, it may deadlock, since the wait will only give up one lock and the notify will be unable to get both locks, and thus the notify will not succeed. If there is also a warning about a two-lock wait, the probability of a problem is quite high.

Mitigation and prevention

Preferably call a notify() method without locks held.

Example 1

9      synchronized void finish(Object o) {
10         synchronized(o) {
11             o.notify();
12         }
13     }

JD.LOCK.NOTIFY is reported for line 11: Calling 'java.lang.Object.notify()' with two or more locks held '[this, o]' could cause a deadlock.

Related checkers