Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8198928

(so) SocketChannel connect may deadlock if closed at around same time that connect fails

    Details

    • Subcomponent:
    • Resolved In Build:
      b04
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      The test java/net/httpclient/TimeoutBasic.java timeout on Linux x64

      result: Error. Program `jdk-11/bin/java' timed out (timeout set to 1200000ms, elapsed time including timeout handling was 1228004ms).

      Please see the jstack output. There is an deadlock identified:
      Full thread dump Java HotSpot(TM) 64-Bit Server VM (11-internal+0-jdk11-jdk.112 mixed mode):

      Threads class SMR info:
      _java_thread_list=0x00007f9628000cd0, length=15, elements={
      0x00007f9714013800, 0x00007f9714263000, 0x00007f9714265000, 0x00007f971427c800,
      0x00007f971427e800, 0x00007f9714281000, 0x00007f9714283000, 0x00007f9714285000,
      0x00007f9714287000, 0x00007f9714344000, 0x00007f9714378800, 0x00007f9714558800,
      0x00007f966c0d8000, 0x00007f9660008000, 0x00007f9698001000
      }

      "main" #1 prio=5 os_prio=0 tid=0x00007f9714013800 nid=0x315 in Object.wait() [0x00007f971c52d000]
         java.lang.Thread.State: WAITING (on object monitor)
      at java.lang.Object.wait(java.base@11-internal/Native Method)
      - waiting on <0x00000000e00e56f0> (a java.lang.Thread)
      at java.lang.Thread.join(java.base@11-internal/Thread.java:1355)
      - waiting to re-lock in wait() <0x00000000e00e56f0> (a java.lang.Thread)
      at java.lang.Thread.join(java.base@11-internal/Thread.java:1429)
      at com.sun.javatest.regtest.agent.MainWrapper.main(MainWrapper.java:74)

      "Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007f9714263000 nid=0x32f waiting on condition [0x00007f96f869e000]
         java.lang.Thread.State: RUNNABLE
      at java.lang.ref.Reference.waitForReferencePendingList(java.base@11-internal/Native Method)
      at java.lang.ref.Reference.processPendingReferences(java.base@11-internal/Reference.java:166)
      at java.lang.ref.Reference.access$000(java.base@11-internal/Reference.java:44)
      at java.lang.ref.Reference$ReferenceHandler.run(java.base@11-internal/Reference.java:138)

      "Finalizer" #3 daemon prio=8 os_prio=0 tid=0x00007f9714265000 nid=0x330 in Object.wait() [0x00007f96f859d000]
         java.lang.Thread.State: WAITING (on object monitor)
      at java.lang.Object.wait(java.base@11-internal/Native Method)
      - waiting on <0x00000000e00f80f0> (a java.lang.ref.ReferenceQueue$Lock)
      at java.lang.ref.ReferenceQueue.remove(java.base@11-internal/ReferenceQueue.java:151)
      - waiting to re-lock in wait() <0x00000000e00f80f0> (a java.lang.ref.ReferenceQueue$Lock)
      at java.lang.ref.ReferenceQueue.remove(java.base@11-internal/ReferenceQueue.java:172)
      at java.lang.ref.Finalizer$FinalizerThread.run(java.base@11-internal/Finalizer.java:170)

      "Signal Dispatcher" #4 daemon prio=9 os_prio=0 tid=0x00007f971427c800 nid=0x331 runnable [0x0000000000000000]
         java.lang.Thread.State: RUNNABLE

      "C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007f971427e800 nid=0x332 waiting on condition [0x0000000000000000]
         java.lang.Thread.State: RUNNABLE
         No compile task

      "C2 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007f9714281000 nid=0x333 waiting on condition [0x0000000000000000]
         java.lang.Thread.State: RUNNABLE
         No compile task

      "C2 CompilerThread2" #7 daemon prio=9 os_prio=0 tid=0x00007f9714283000 nid=0x334 waiting on condition [0x0000000000000000]
         java.lang.Thread.State: RUNNABLE
         No compile task

      "C1 CompilerThread3" #8 daemon prio=9 os_prio=0 tid=0x00007f9714285000 nid=0x335 waiting on condition [0x0000000000000000]
         java.lang.Thread.State: RUNNABLE
         No compile task

      "Sweeper thread" #9 daemon prio=9 os_prio=0 tid=0x00007f9714287000 nid=0x336 runnable [0x0000000000000000]
         java.lang.Thread.State: RUNNABLE

      "Service Thread" #10 daemon prio=9 os_prio=0 tid=0x00007f9714344000 nid=0x337 runnable [0x0000000000000000]
         java.lang.Thread.State: RUNNABLE

      "Common-Cleaner" #11 daemon prio=8 os_prio=0 tid=0x00007f9714378800 nid=0x338 in Object.wait() [0x00007f96c94fb000]
         java.lang.Thread.State: TIMED_WAITING (on object monitor)
      at java.lang.Object.wait(java.base@11-internal/Native Method)
      - waiting on <0x00000000e0c0d9c8> (a java.lang.ref.ReferenceQueue$Lock)
      at java.lang.ref.ReferenceQueue.remove(java.base@11-internal/ReferenceQueue.java:151)
      - waiting to re-lock in wait() <0x00000000e0c0d9c8> (a java.lang.ref.ReferenceQueue$Lock)
      at jdk.internal.ref.CleanerImpl.run(java.base@11-internal/CleanerImpl.java:148)
      at java.lang.Thread.run(java.base@11-internal/Thread.java:842)
      at jdk.internal.misc.InnocuousThread.run(java.base@11-internal/InnocuousThread.java:134)

      "MainThread" #13 prio=5 os_prio=0 tid=0x00007f9714558800 nid=0x33a waiting on condition [0x00007f96c8ed0000]
         java.lang.Thread.State: WAITING (parking)
      at jdk.internal.misc.Unsafe.park(java.base@11-internal/Native Method)
      - parking to wait for <0x00000000e02221c8> (a java.util.concurrent.CompletableFuture$Signaller)
      at java.util.concurrent.locks.LockSupport.park(java.base@11-internal/LockSupport.java:194)
      at java.util.concurrent.CompletableFuture$Signaller.block(java.base@11-internal/CompletableFuture.java:1796)
      at java.util.concurrent.ForkJoinPool.managedBlock(java.base@11-internal/ForkJoinPool.java:3156)
      at java.util.concurrent.CompletableFuture.waitingGet(java.base@11-internal/CompletableFuture.java:1823)
      at java.util.concurrent.CompletableFuture.join(java.base@11-internal/CompletableFuture.java:2043)
      at TimeoutBasic.test(TimeoutBasic.java:155)
      at TimeoutBasic.main(TimeoutBasic.java:91)
      at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@11-internal/Native Method)
      at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@11-internal/NativeMethodAccessorImpl.java:62)
      at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@11-internal/DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(java.base@11-internal/Method.java:564)
      at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:115)
      at java.lang.Thread.run(java.base@11-internal/Thread.java:842)

      "HttpClient-6-SelectorManager" #35 daemon prio=5 os_prio=0 tid=0x00007f966c0d8000 nid=0x3d4 waiting on condition [0x00007f96c8176000]
         java.lang.Thread.State: WAITING (parking)
      at jdk.internal.misc.Unsafe.park(java.base@11-internal/Native Method)
      - parking to wait for <0x00000000e0cbf6a0> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
      at java.util.concurrent.locks.LockSupport.park(java.base@11-internal/LockSupport.java:194)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(java.base@11-internal/AbstractQueuedSynchronizer.java:885)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(java.base@11-internal/AbstractQueuedSynchronizer.java:917)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(java.base@11-internal/AbstractQueuedSynchronizer.java:1240)
      at java.util.concurrent.locks.ReentrantLock.lock(java.base@11-internal/ReentrantLock.java:267)
      at sun.nio.ch.SocketChannelImpl.implCloseSelectableChannel(java.base@11-internal/SocketChannelImpl.java:839)
      at java.nio.channels.spi.AbstractSelectableChannel.implCloseChannel(java.base@11-internal/AbstractSelectableChannel.java:241)
      at java.nio.channels.spi.AbstractInterruptibleChannel.close(java.base@11-internal/AbstractInterruptibleChannel.java:112)
      - locked <0x00000000e0cbf660> (a java.lang.Object)
      at jdk.incubator.http.PlainHttpConnection.close(jdk.incubator.httpclient@11-internal/PlainHttpConnection.java:189)
      - locked <0x00000000e0cbf378> (a jdk.incubator.http.PlainHttpConnection)
      at jdk.incubator.http.Http1Exchange.cancelImpl(jdk.incubator.httpclient@11-internal/Http1Exchange.java:379)
      - locked <0x00000000e0cbf128> (a java.lang.Object)
      at jdk.incubator.http.Http1Exchange.cancel(jdk.incubator.httpclient@11-internal/Http1Exchange.java:366)
      at jdk.incubator.http.Exchange.cancel(jdk.incubator.httpclient@11-internal/Exchange.java:174)
      at jdk.incubator.http.MultiExchange.cancel(jdk.incubator.httpclient@11-internal/MultiExchange.java:212)
      at jdk.incubator.http.MultiExchange$TimedEvent.handle(jdk.incubator.httpclient@11-internal/MultiExchange.java:354)
      at jdk.incubator.http.HttpClientImpl.purgeTimeoutsAndReturnNextDeadline(jdk.incubator.httpclient@11-internal/HttpClientImpl.java:1019)
      at jdk.incubator.http.HttpClientImpl.access$300(jdk.incubator.httpclient@11-internal/HttpClientImpl.java:76)
      at jdk.incubator.http.HttpClientImpl$SelectorManager.run(jdk.incubator.httpclient@11-internal/HttpClientImpl.java:698)

      "HttpClient-6-Worker-2" #38 daemon prio=5 os_prio=0 tid=0x00007f9660008000 nid=0x3d8 waiting for monitor entry [0x00007f965aceb000]
         java.lang.Thread.State: BLOCKED (on object monitor)
      at java.nio.channels.spi.AbstractInterruptibleChannel.close(java.base@11-internal/AbstractInterruptibleChannel.java:109)
      - waiting to lock <0x00000000e0cbf660> (a java.lang.Object)
      at sun.nio.ch.SocketChannelImpl.connect(java.base@11-internal/SocketChannelImpl.java:663)
      at jdk.incubator.http.PlainHttpConnection.lambda$connectAsync$0(jdk.incubator.httpclient@11-internal/PlainHttpConnection.java:110)
      at jdk.incubator.http.PlainHttpConnection$$Lambda$62/0x000000010014dc30.run(jdk.incubator.httpclient@11-internal/Unknown Source)
      at java.security.AccessController.doPrivileged(java.base@11-internal/Native Method)
      at jdk.incubator.http.PlainHttpConnection.connectAsync(jdk.incubator.httpclient@11-internal/PlainHttpConnection.java:112)
      at jdk.incubator.http.Http1Exchange.sendHeadersAsync(jdk.incubator.httpclient@11-internal/Http1Exchange.java:234)
      at jdk.incubator.http.Exchange.lambda$responseAsyncImpl0$8(jdk.incubator.httpclient@11-internal/Exchange.java:322)
      at jdk.incubator.http.Exchange$$Lambda$75/0x0000000100151830.apply(jdk.incubator.httpclient@11-internal/Unknown Source)
      at java.util.concurrent.CompletableFuture.uniComposeStage(java.base@11-internal/CompletableFuture.java:1106)
      at java.util.concurrent.CompletableFuture.thenCompose(java.base@11-internal/CompletableFuture.java:2235)
      at jdk.incubator.http.Exchange.responseAsyncImpl0(jdk.incubator.httpclient@11-internal/Exchange.java:322)
      at jdk.incubator.http.Exchange.responseAsyncImpl(jdk.incubator.httpclient@11-internal/Exchange.java:286)
      at jdk.incubator.http.Exchange.responseAsync(jdk.incubator.httpclient@11-internal/Exchange.java:278)
      at jdk.incubator.http.MultiExchange.responseAsyncImpl(jdk.incubator.httpclient@11-internal/MultiExchange.java:268)
      at jdk.incubator.http.MultiExchange.lambda$responseAsync0$1(jdk.incubator.httpclient@11-internal/MultiExchange.java:224)
      at jdk.incubator.http.MultiExchange$$Lambda$46/0x0000000100123c30.apply(jdk.incubator.httpclient@11-internal/Unknown Source)
      at java.util.concurrent.CompletableFuture$UniCompose.tryFire(java.base@11-internal/CompletableFuture.java:1072)
      at java.util.concurrent.CompletableFuture.postComplete(java.base@11-internal/CompletableFuture.java:506)
      at java.util.concurrent.CompletableFuture$AsyncSupply.run(java.base@11-internal/CompletableFuture.java:1705)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@11-internal/ThreadPoolExecutor.java:1128)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@11-internal/ThreadPoolExecutor.java:628)
      at java.lang.Thread.run(java.base@11-internal/Thread.java:842)

      "Attach Listener" #39 daemon prio=9 os_prio=0 tid=0x00007f9698001000 nid=0x5283 waiting on condition [0x0000000000000000]
         java.lang.Thread.State: RUNNABLE

      "VM Thread" os_prio=0 tid=0x00007f9714259000 nid=0x32e runnable

      "GC Thread#0" os_prio=0 tid=0x00007f9714029800 nid=0x316 runnable

      "GC Thread#1" os_prio=0 tid=0x00007f971402b000 nid=0x317 runnable

      "GC Thread#2" os_prio=0 tid=0x00007f971402d000 nid=0x318 runnable

      "GC Thread#3" os_prio=0 tid=0x00007f971402e800 nid=0x319 runnable

      "GC Thread#4" os_prio=0 tid=0x00007f9714030800 nid=0x31b runnable

      "GC Thread#5" os_prio=0 tid=0x00007f9714032800 nid=0x31c runnable

      "GC Thread#6" os_prio=0 tid=0x00007f9714034000 nid=0x31d runnable

      "GC Thread#7" os_prio=0 tid=0x00007f9714036000 nid=0x31e runnable

      "G1 Main Marker" os_prio=0 tid=0x00007f9714056000 nid=0x31f runnable

      "G1 Conc#0" os_prio=0 tid=0x00007f9714058000 nid=0x320 runnable

      "G1 Conc#1" os_prio=0 tid=0x00007f9714059800 nid=0x323 runnable

      "G1 Refine#0" os_prio=0 tid=0x00007f97141ea800 nid=0x324 runnable

      "G1 Refine#1" os_prio=0 tid=0x00007f97141ec800 nid=0x325 runnable

      "G1 Refine#2" os_prio=0 tid=0x00007f97141ee000 nid=0x326 runnable

      "G1 Refine#3" os_prio=0 tid=0x00007f97141f0000 nid=0x327 runnable

      "G1 Refine#4" os_prio=0 tid=0x00007f97141f2000 nid=0x328 runnable

      "G1 Refine#5" os_prio=0 tid=0x00007f97141f3800 nid=0x329 runnable

      "G1 Refine#6" os_prio=0 tid=0x00007f97141f5800 nid=0x32a runnable

      "G1 Refine#7" os_prio=0 tid=0x00007f97141f7800 nid=0x32b runnable

      "G1 Young RemSet Sampling" os_prio=0 tid=0x00007f97141f9000 nid=0x32c runnable
      "VM Periodic Task Thread" os_prio=0 tid=0x00007f971437a800 nid=0x339 waiting on condition

      JNI global refs: 15, weak refs: 0


      Found one Java-level deadlock:
      =============================
      "HttpClient-6-SelectorManager":
        waiting for ownable synchronizer 0x00000000e0cbf6a0, (a java.util.concurrent.locks.ReentrantLock$NonfairSync),
        which is held by "HttpClient-6-Worker-2"
      "HttpClient-6-Worker-2":
        waiting to lock monitor 0x00007f96a0008b00 (object 0x00000000e0cbf660, a java.lang.Object),
        which is held by "HttpClient-6-SelectorManager"

      Java stack information for the threads listed above:
      ===================================================
      "HttpClient-6-SelectorManager":
      at jdk.internal.misc.Unsafe.park(java.base@11-internal/Native Method)
      - parking to wait for <0x00000000e0cbf6a0> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
      at java.util.concurrent.locks.LockSupport.park(java.base@11-internal/LockSupport.java:194)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(java.base@11-internal/AbstractQueuedSynchronizer.java:885)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(java.base@11-internal/AbstractQueuedSynchronizer.java:917)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(java.base@11-internal/AbstractQueuedSynchronizer.java:1240)
      at java.util.concurrent.locks.ReentrantLock.lock(java.base@11-internal/ReentrantLock.java:267)
      at sun.nio.ch.SocketChannelImpl.implCloseSelectableChannel(java.base@11-internal/SocketChannelImpl.java:839)
      at java.nio.channels.spi.AbstractSelectableChannel.implCloseChannel(java.base@11-internal/AbstractSelectableChannel.java:241)
      at java.nio.channels.spi.AbstractInterruptibleChannel.close(java.base@11-internal/AbstractInterruptibleChannel.java:112)
      - locked <0x00000000e0cbf660> (a java.lang.Object)
      at jdk.incubator.http.PlainHttpConnection.close(jdk.incubator.httpclient@11-internal/PlainHttpConnection.java:189)
      - locked <0x00000000e0cbf378> (a jdk.incubator.http.PlainHttpConnection)
      at jdk.incubator.http.Http1Exchange.cancelImpl(jdk.incubator.httpclient@11-internal/Http1Exchange.java:379)
      - locked <0x00000000e0cbf128> (a java.lang.Object)
      at jdk.incubator.http.Http1Exchange.cancel(jdk.incubator.httpclient@11-internal/Http1Exchange.java:366)
      at jdk.incubator.http.Exchange.cancel(jdk.incubator.httpclient@11-internal/Exchange.java:174)
      at jdk.incubator.http.MultiExchange.cancel(jdk.incubator.httpclient@11-internal/MultiExchange.java:212)
      at jdk.incubator.http.MultiExchange$TimedEvent.handle(jdk.incubator.httpclient@11-internal/MultiExchange.java:354)
      at jdk.incubator.http.HttpClientImpl.purgeTimeoutsAndReturnNextDeadline(jdk.incubator.httpclient@11-internal/HttpClientImpl.java:1019)
      at jdk.incubator.http.HttpClientImpl.access$300(jdk.incubator.httpclient@11-internal/HttpClientImpl.java:76)
      at jdk.incubator.http.HttpClientImpl$SelectorManager.run(jdk.incubator.httpclient@11-internal/HttpClientImpl.java:698)
      "HttpClient-6-Worker-2":
      at java.nio.channels.spi.AbstractInterruptibleChannel.close(java.base@11-internal/AbstractInterruptibleChannel.java:109)
      - waiting to lock <0x00000000e0cbf660> (a java.lang.Object)
      at sun.nio.ch.SocketChannelImpl.connect(java.base@11-internal/SocketChannelImpl.java:663)
      at jdk.incubator.http.PlainHttpConnection.lambda$connectAsync$0(jdk.incubator.httpclient@11-internal/PlainHttpConnection.java:110)
      at jdk.incubator.http.PlainHttpConnection$$Lambda$62/0x000000010014dc30.run(jdk.incubator.httpclient@11-internal/Unknown Source)
      at java.security.AccessController.doPrivileged(java.base@11-internal/Native Method)
      at jdk.incubator.http.PlainHttpConnection.connectAsync(jdk.incubator.httpclient@11-internal/PlainHttpConnection.java:112)
      at jdk.incubator.http.Http1Exchange.sendHeadersAsync(jdk.incubator.httpclient@11-internal/Http1Exchange.java:234)
      at jdk.incubator.http.Exchange.lambda$responseAsyncImpl0$8(jdk.incubator.httpclient@11-internal/Exchange.java:322)
      at jdk.incubator.http.Exchange$$Lambda$75/0x0000000100151830.apply(jdk.incubator.httpclient@11-internal/Unknown Source)
      at java.util.concurrent.CompletableFuture.uniComposeStage(java.base@11-internal/CompletableFuture.java:1106)
      at java.util.concurrent.CompletableFuture.thenCompose(java.base@11-internal/CompletableFuture.java:2235)
      at jdk.incubator.http.Exchange.responseAsyncImpl0(jdk.incubator.httpclient@11-internal/Exchange.java:322)
      at jdk.incubator.http.Exchange.responseAsyncImpl(jdk.incubator.httpclient@11-internal/Exchange.java:286)
      at jdk.incubator.http.Exchange.responseAsync(jdk.incubator.httpclient@11-internal/Exchange.java:278)
      at jdk.incubator.http.MultiExchange.responseAsyncImpl(jdk.incubator.httpclient@11-internal/MultiExchange.java:268)
      at jdk.incubator.http.MultiExchange.lambda$responseAsync0$1(jdk.incubator.httpclient@11-internal/MultiExchange.java:224)
      at jdk.incubator.http.MultiExchange$$Lambda$46/0x0000000100123c30.apply(jdk.incubator.httpclient@11-internal/Unknown Source)
      at java.util.concurrent.CompletableFuture$UniCompose.tryFire(java.base@11-internal/CompletableFuture.java:1072)
      at java.util.concurrent.CompletableFuture.postComplete(java.base@11-internal/CompletableFuture.java:506)
      at java.util.concurrent.CompletableFuture$AsyncSupply.run(java.base@11-internal/CompletableFuture.java:1705)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@11-internal/ThreadPoolExecutor.java:1128)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@11-internal/ThreadPoolExecutor.java:628)
      at java.lang.Thread.run(java.base@11-internal/Thread.java:842)

      Found 1 deadlock.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alanb Alan Bateman
                Reporter:
                jwang Joy Wang
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: