Details

    • Subcomponent:
    • Resolved In Build:
      b07
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        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

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  dtitov Daniil Titov
                  Reporter:
                  xliu Xin Liu
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: