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

Deadlock in java.beans.XMLDecoder

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 7
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux_ubuntu

      Description

      FULL PRODUCT VERSION :
      java version "1.7.0_07"
      Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
      Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux 2.6.18-194.32.1.el5 #1 SMP Wed Jan 5 17:52:25 EST 2011 x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Our application uses java.beans.XMLEncoder/XMLDecoder in multiple threads (with a separate instance per thread - no object sharing).
      The application became unresponsive because of a deadlock within the JRE code that supports XMLDecoder.

      Here are the relevant pieces of the stack trace:

      "http-80-23" daemon prio=10 tid=0x000000000a372000 nid=0x49b runnable [0x0000000046ce0000]
         java.lang.Thread.State: RUNNABLE
      at java.util.WeakHashMap.expungeStaleEntries(WeakHashMap.java:408)
      - locked <0x00000004006f9f90> (a java.lang.ref.ReferenceQueue)
      at java.util.WeakHashMap.getTable(WeakHashMap.java:417)
      at java.util.WeakHashMap.get(WeakHashMap.java:464)
      at com.sun.beans.WeakCache.get(WeakCache.java:55)
      at com.sun.beans.finder.MethodFinder.findMethod(MethodFinder.java:66)
      at java.beans.Statement.getMethod(Statement.java:357)
      at java.beans.Statement.invokeInternal(Statement.java:261)
      at java.beans.Statement.access$000(Statement.java:58)
      at java.beans.Statement$2.run(Statement.java:185)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.beans.Statement.invoke(Statement.java:182)
      at java.beans.Expression.getValue(Expression.java:153)
      at com.sun.beans.decoder.ObjectElementHandler.getValueObject(ObjectElementHandler.java:166)
      at com.sun.beans.decoder.NewElementHandler.getValueObject(NewElementHandler.java:123)
      at com.sun.beans.decoder.ElementHandler.getContextBean(ElementHandler.java:113)
      at com.sun.beans.decoder.NewElementHandler.getContextBean(NewElementHandler.java:109)
      at com.sun.beans.decoder.ObjectElementHandler.getValueObject(ObjectElementHandler.java:146)
      at com.sun.beans.decoder.NewElementHandler.getValueObject(NewElementHandler.java:123)
      at com.sun.beans.decoder.ElementHandler.endElement(ElementHandler.java:169)
      at com.sun.beans.decoder.DocumentHandler.endElement(DocumentHandler.java:305)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:606)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1742)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2900)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
      at com.sun.beans.decoder.DocumentHandler.parse(DocumentHandler.java:356)
      at java.beans.XMLDecoder.parsingComplete(XMLDecoder.java:192)
      at java.beans.XMLDecoder.close(XMLDecoder.java:170)
      at com.adlucent.servlet.OrderProcessServlet.doPost(OrderProcessServlet.java:68)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Thread.java:722)

      "http-80-22" daemon prio=10 tid=0x00000000093ae000 nid=0x49a waiting for monitor entry [0x0000000046fab000]
         java.lang.Thread.State: BLOCKED (on object monitor)
      at java.util.WeakHashMap.expungeStaleEntries(WeakHashMap.java:386)
      - waiting to lock <0x00000004006f9f90> (a java.lang.ref.ReferenceQueue)
      at java.util.WeakHashMap.getTable(WeakHashMap.java:417)
      at java.util.WeakHashMap.get(WeakHashMap.java:464)
      at com.sun.beans.WeakCache.get(WeakCache.java:55)
      at com.sun.beans.finder.MethodFinder.findMethod(MethodFinder.java:66)
      at java.beans.Statement.getMethod(Statement.java:357)
      at java.beans.Statement.invokeInternal(Statement.java:261)
      at java.beans.Statement.access$000(Statement.java:58)
      at java.beans.Statement$2.run(Statement.java:185)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.beans.Statement.invoke(Statement.java:182)
      at java.beans.Expression.getValue(Expression.java:153)
      at com.sun.beans.decoder.ObjectElementHandler.getValueObject(ObjectElementHandler.java:166)
      at com.sun.beans.decoder.NewElementHandler.getValueObject(NewElementHandler.java:123)
      at com.sun.beans.decoder.ElementHandler.getContextBean(ElementHandler.java:113)
      at com.sun.beans.decoder.NewElementHandler.getContextBean(NewElementHandler.java:109)
      at com.sun.beans.decoder.ObjectElementHandler.getValueObject(ObjectElementHandler.java:146)
      at com.sun.beans.decoder.NewElementHandler.getValueObject(NewElementHandler.java:123)
      at com.sun.beans.decoder.ElementHandler.endElement(ElementHandler.java:169)
      at com.sun.beans.decoder.DocumentHandler.endElement(DocumentHandler.java:305)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:606)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1742)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2900)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
      at com.sun.beans.decoder.DocumentHandler.parse(DocumentHandler.java:356)
      at java.beans.XMLDecoder.parsingComplete(XMLDecoder.java:192)
      at java.beans.XMLDecoder.close(XMLDecoder.java:170)
      at com.adlucent.servlet.OrderProcessServlet.doPost(OrderProcessServlet.java:68)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Thread.java:722)

      There are approximately 500 other threads like the BLOCKED thread above.

      We examined the source code available for com.sun.beans.WeakCache and found that it is using a WeakHashMap without synchronization.
      This is incorrect and most likely the cause of the problem.

      The suggested fix is to make all methods of WeakCache 'synchronized', since they all access the enclosed WeakHashMap.


      REGRESSION. Last worked in version 5.0

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Not easily reproducible since it involves multiple threads as well as the garbage collector.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No deadlock.
      ACTUAL -
      Application deadlocked in JRE code.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      See stack traces above.

      REPRODUCIBILITY :
      This bug can be reproduced rarely.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              malenkov Sergey Malenkov (Inactive)
              Reporter:
              malenkov Sergey Malenkov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported: