Skip to main content

Infinite loop in com.sun.org.apache.xerces.internal.impl.XMLDocumentScanner

3 replies [Last post]
stevehale
Offline
Joined: 2010-09-20
Points: 0

Threads in my web service get into an infinite loop within the "com.sun" version of XMLDocumentScannerImpl. Comparing the source code in the PrologDriver.next method with the source code in Xerces PrologDispatcher.dispatch method, it appears that the former does not contain all the right checks to avoid an infinite loop. The SOAP message may be malformed, but I have not been able to capture one that might cause the loop.

"myThread-70046" daemon prio=10 tid=0x00000000618fe000 nid=0x71f2 runnable [0x000000004a036000]
java.lang.Thread.State: RUNNABLE
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:931)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:548)
at org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:44)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
stevehale
Offline
Joined: 2010-09-20
Points: 0

I will be entering this as a bug against the SJSXP (Sun's StAX implementation) included as the default StAX implementation of JAXP interface in the JDK.

Environment is Tomcat 5.5_23 running JDK 1.6.0_15

I discovered that JDK 1.6.0_18 had a JAXP upgrade (1.4.3 I think), and another JAXP upgrade (to 1.4.4) is planned for JDK 1.6.0_23, while the current available release as of this writting is 1.6.0_21. However the source code around the area of the infinite loop (a do-while loop in XMLDocumentScannerImpl.java that checks the scanner state, but the state isn't changed under certain if-else conditions) does NOT appear to have been modified even in JAXP 1.4.4.

I was concentrating on "redirecting" SAX (SAXParserFactory) to use the Xerces 2.10.0 implementation, but found that the SJSXP StAX implementation doesn't use SAX via the SAXParserFactory but instead calls the same internal methods used by the SJSXP SAX implementation (XMLDocumentScannerImpl.java). It appears the only work-around is to use a different StAX implementation, namely Woodstox.

joehw
Offline
Joined: 2004-12-15
Points: 0

Yes, please file a bug against SJSXP.

stevehale
Offline
Joined: 2010-09-20
Points: 0