JDK-6976938 : StackOverflowError by com.sun.xml.stream.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next
  • Type: Bug
  • Component: xml
  • Sub-Component: javax.xml.stream
  • Affected Version: 1.0
  • Priority: P5
  • Status: Closed
  • Resolution: Not an Issue
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2010-08-13
  • Updated: 2012-04-25
  • Resolved: 2011-01-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6 JDK 7
1.4.0Fixed 6u24-revFixed 7Fixed
Related Reports
Relates :  
Description
Operating System
----------------------
SPARC Solaris 10 (but reproduceible at any OS)
Due to bigger Solaris OS default of pagesize(1) of 8k, the issue is 
faster reproduceible at sparc architecture.

StAX Version
----------------------
issue persist at any StAX (eg.lastest JDK6 or Glassfish or latest StAX 1.0.2 from dev.java.net)

Description
----------------------
Customer is running StAX at Application Server to read XML files.
Quite similar to CR#6440214 the StAX scanner produce a java.lang.StackOverflowError while 
reading valid XML files, in case the text content of a XML element contains many lines like "< ... >".
As more new lines with "< ... >" will be added, as bigger java stack is consumed, caused by the StAX scanner.
However the given workaround from CR#6440214 to set "IS_COALESCING, Boolean.FALSE" do not work
in our test case. The seen error message is additional a bit different which is the reason for another bugreport.
Setting IS_COALESCING to FALSE cause only a very small effect to reduce the amound of
used stack size by just a few bytes.

Testcase attached 
----------------------
- sample XML file which cause the issue
- the runnable testcase

Howto run the testcase
----------------------
- download and extract latest ant if you dont have ant installed
- Please unzip the test case and run on sparc to reproduce the error
$ ant -Dplatform.home=/your/path/to/jdk1.5.0_xx -Drun.jvmargs="-server" clean test

- Please run on sparc this command to prevent the error
$ ant -Dplatform.home=/your/path/to/jdk1.5.0_xx -Drun.jvmargs="-server -Xss800k" clean test

- To simulate the error with Solaris x86, use ppgsz(1) 
call pagesize -a and pickup a valid pagesize bigger then 8k and call the ant command at x86 like this
$ ppgsz -o stack=2097152 ant -Dplatform.home=/opt/jdk1.5.0_22-32 -Drun.jvmargs="-server" clean test 

Error Messages
-----------------------
java.lang.StackOverflowError
	at com.sun.xml.stream.XMLEntityReaderImpl.scanName(XMLEntityReaderImpl.java:700)
	at com.sun.xml.stream.XMLDocumentFragmentScannerImpl.scanEntityReference(XMLDocumentFragmentScannerImpl.java:1723)
	at com.sun.xml.stream.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2936)
	at com.sun.xml.stream.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2819)
	at com.sun.xml.stream.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2962)
	at com.sun.xml.stream.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2819)
	at com.sun.xml.stream.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2962)
	at com.sun.xml.stream.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2819)
	at com.sun.xml.stream.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2962)
	at com.sun.xml.stream.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2819)
	at com.sun.xml.stream.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2962)
...
...

Comments
EVALUATION The impacted classes for this fix do not exist in JDK5 the reason being, this functionality is provided with a separate sjsxp.jar and has been incorporated into JDK only since JDK6. Hence this fix is not applicable to JDK5. Closing the SubCR.
04-01-2011

EVALUATION Note that this issue has been fixed in both sjsxp and jaxp 1.4 by 11/08/10. It's shown on bugs.sun.com (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6976938) as still open because that for jaxp 1.4 was created as a sub-CR.
01-12-2010

WORK AROUND Issue does not happen in case the valid xml text data is stored within <![CDATA[ ... ]]> text. However the workaround is not usable for many customers, in case they read valid XML from external resources. The codehaus woodstox implementation dont have this issue.
13-08-2010