Uploaded image for project: 'HttpComponents HttpCore'
  1. HttpComponents HttpCore
  2. HTTPCORE-575

Deadlock found in IOSessionImpl in httpcomponents-core

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 4.4.10
    • Fix Version/s: None
    • Component/s: HttpCore, HttpCore NIO
    • Labels:
      None

      Description

      Hi, I'm using below components:

      httpcore-nio:4.4.10

      httpasyncclient:4.1.4.3

      jdk:1.8.0.131

      and It caused deadlock when closing the connection pool:

      below is thread 1 stack:

      sitemon-async-http-client-io-dispatch-thread20-48
      priority:5 - threadId:0x00000000022b6800 - nativeId:0x2068 - nativeId (decimal):8296 - state:BLOCKED
      stackTrace:
      java.lang.Thread.State: BLOCKED (on object monitor)
      at java.nio.channels.spi.AbstractInterruptibleChannel.close(AbstractInterruptibleChannel.java:111)
      - waiting to lock <0x00000007495b4738> (a java.lang.Object)
      at org.apache.http.impl.nio.reactor.IOSessionImpl.close(IOSessionImpl.java:227)
      - locked <0x00000007495b4808> (a sun.nio.ch.SelectionKeyImpl)
      at org.apache.http.impl.nio.reactor.IOSessionImpl.shutdown(IOSessionImpl.java:255)
      at org.apache.http.impl.nio.reactor.AbstractIODispatch.connected(AbstractIODispatch.java:89)
      at org.apache.http.impl.nio.client.LMIODispatcher.connected(LMIODispatcher.java:32)
      at org.apache.http.impl.nio.reactor.BaseIOReactor.sessionCreated(BaseIOReactor.java:248)
      at org.apache.http.impl.nio.reactor.AbstractIOReactor.processNewChannels(AbstractIOReactor.java:427)
      at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:287)
      at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
      at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:588)
      at java.lang.Thread.run(Thread.java:748)
      
      
      

       

      below is thread 2 stack:

      sitemon-webservice-task-thread-11-3 priority:5 - threadId:0x00007fb840052800 - nativeId:0x1ee9 - nativeId (decimal):7913 - state:BLOCKED stackTrace: java.lang.Thread.State: BLOCKED (on object monitor) at java.nio.channels.spi.AbstractSelectionKey.cancel(AbstractSelectionKey.java:70) - waiting to lock <0x00000007495b4808> (a sun.nio.ch.SelectionKeyImpl) at java.nio.channels.spi.AbstractSelectableChannel.implCloseChannel(AbstractSelectableChannel.java:240) - locked <0x00000007495bb1f0> (a java.lang.Object) at java.nio.channels.spi.AbstractInterruptibleChannel.close(AbstractInterruptibleChannel.java:115) - locked <0x00000007495b4738> (a java.lang.Object) at org.apache.http.impl.nio.reactor.SessionRequestImpl.cancel(SessionRequestImpl.java:216) 
      at org.apache.http.nio.pool.AbstractNIOConnPool.shutdown(AbstractNIOConnPool.java:217)
      // .... suppressed
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:748)
      
      

      Please note the object in bold (0x00000007495b4738  and 0x00000007495b4808**)

      in thread 1, it get locks with selection key -> then channel

      in thread 2, it get locks with channel -> then selection key.

       the class LMIODispatcher only did a time recording of method super.connected()

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                olegk Oleg Kalnichevski
                Reporter:
                edwardg Edward Gao
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: