-
Bug
-
Resolution: Fixed
-
P3
-
8, 11, 13, 14
-
b07
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8245932 | 13.0.4 | Daniil Titov | P3 | Resolved | Fixed | b03 |
JDK-8237771 | 11.0.7 | Daniil Titov | P3 | Resolved | Fixed | b01 |
JDK-8237836 | openjdk8u252 | Daniil Titov | P3 | Resolved | Fixed | b01 |
The code in Worker.java acquires synchronization objects in different order (once acquires jobs and then this, another time acquires this and then jobs).
Acquiring synchronization objects in different order can cause circular wait (deadlock).
Here is the first order: (1) first acquire jobs and then this:
enter public method run() at line 40
acquire synchronization on jobs at line 43
call isStopped() at line 44
acquire synchronization on this at entry to isStopped() because isStopped() is
a synchronized method --- see line 59
Here is the second order: (2) first acquire this and then jobs:
enter public method stopWorker() at line 63
acquire synchronization on this at entry to stopWorker() because stopWorker() is a synchronized method --- see line 63
acquire synchronization on jobs at line 65
A possible bugfix is making code always acquire synchronization in only 1 order: first acquire jobs and then this.
public void stopWorker() { <<<<<<<<<<<<<<<< moved synchronized from here to below as "synchronized(this)"
synchronized(jobs) {
synchronized(this) { <<<<<<<<<<<<<<<<<<<<<<<<<< added this
stopped = true;
jobs.notify();
}
}
}
Reference
https://hg.openjdk.java.net/jdk/jdk/file/b997e5b9479b/src/jdk.jconsole/share/classes/sun/tools/jconsole/Worker.java#l63
Acquiring synchronization objects in different order can cause circular wait (deadlock).
Here is the first order: (1) first acquire jobs and then this:
enter public method run() at line 40
acquire synchronization on jobs at line 43
call isStopped() at line 44
acquire synchronization on this at entry to isStopped() because isStopped() is
a synchronized method --- see line 59
Here is the second order: (2) first acquire this and then jobs:
enter public method stopWorker() at line 63
acquire synchronization on this at entry to stopWorker() because stopWorker() is a synchronized method --- see line 63
acquire synchronization on jobs at line 65
A possible bugfix is making code always acquire synchronization in only 1 order: first acquire jobs and then this.
public void stopWorker() { <<<<<<<<<<<<<<<< moved synchronized from here to below as "synchronized(this)"
synchronized(jobs) {
synchronized(this) { <<<<<<<<<<<<<<<<<<<<<<<<<< added this
stopped = true;
jobs.notify();
}
}
}
Reference
https://hg.openjdk.java.net/jdk/jdk/file/b997e5b9479b/src/jdk.jconsole/share/classes/sun/tools/jconsole/Worker.java#l63
- backported by
-
JDK-8237771 Worker has a deadlock bug
-
- Resolved
-
-
JDK-8237836 Worker has a deadlock bug
-
- Resolved
-
-
JDK-8245932 Worker has a deadlock bug
-
- Resolved
-
- duplicates
-
JDK-8236872 worker has a deadlock bug in jconsole
-
- Closed
-
- relates to
-
JDK-8254683 [TEST_BUG] jdk/test/sun/tools/jconsole/WorkerDeadlockTest.java fails
-
- Resolved
-