Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7901807

Deadlock while trying to remove Handler during termination

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • None
    • None
    • tools
    • None

      Observed lots of timeouts caused by a synchronization issue in between BinaryLinkServer::terminate() that is invoked by the JCStress::run() and tries to join handlers with:
      72 synchronized (handlers) {
      73 for (Handler h : handlers) {
      74 h.join();
      75 }
      76 }
      in BinaryLinkServer.
      At the same time Handler tries tor remove itself from the handlers = Collections.synchronizedCollection(new ArrayList<>())
      205 handlers.remove(this);

      It looks like in case of the failed binary connection this leads to a deadlock.
      "Thread-16" #43 prio=5 os_prio=0 tid=0x00007ffbd4001800 nid=0x33db waiting for monitor entry [0x00007ffc455b6000]
         java.lang.Thread.State: BLOCKED (on object monitor)
      at java.util.Collections$SynchronizedCollection.remove(java.base@9-internal/Collections.java:2039)
      - waiting to lock <0x0000000101254178> (a java.util.Collections$SynchronizedCollection)
      at org.openjdk.jcstress.link.BinaryLinkServer$Handler.run(BinaryLinkServer.java:205)

      "main" #1 prio=5 os_prio=0 tid=0x00007ffd8800f000 nid=0x314f in Object.wait() [0x00007ffd91d0b000]
         java.lang.Thread.State: WAITING (on object monitor)
      at java.lang.Object.wait(java.base@9-internal/Native Method)
      - waiting on <0x00000001013ccd98> (a org.openjdk.jcstress.link.BinaryLinkServer$Handler)
      at java.lang.Thread.join(java.base@9-internal/Thread.java:1352)
      - waiting to re-lock in wait() <0x00000001013ccd98> (a org.openjdk.jcstress.link.BinaryLinkServer$Handler)
      at java.lang.Thread.join(java.base@9-internal/Thread.java:1426)
      at org.openjdk.jcstress.link.BinaryLinkServer.terminate(BinaryLinkServer.java:74)
      - locked <0x0000000101254178> (a java.util.Collections$SynchronizedCollection)
      at org.openjdk.jcstress.JCStress.run(JCStress.java:128)
      at org.openjdk.jcstress.Main.main(Main.java:60)

            shade Aleksey Shipilev
            ppunegov Pavel Punegov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: