XalanJ2
  1. XalanJ2
  2. XALANJ-2526

StackOverflowError at at org.apache.xml.serializer.ToStream.characters(ToStream.java:1624)

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: 2.7.1
    • Fix Version/s: None
    • Component/s: None
    • Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
    • Labels:
      None
    • Environment:
      Linux, Java 1.6.0_21, Xalan 2.7.1

      Description

      Using the Anttask Junit-Report with an xslt to generate the Junitreport I'm getting this error from the JDK xml parser:

      -----------------------------------------------------------------------------------------------------------
      This is the stacktrace from the JDK Xalan, but below is the output of the "normal" Xalan 2.7.1
      -----------------------------------------------------------------------------------------------------------

      Caused by: java.lang.StackOverflowError
      at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
      at org.apache.tools.ant.Task.perform(Task.java:348)
      at org.apache.tools.ant.Target.execute(Target.java:390)
      at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:211)
      ... 22 more
      Caused by: java.lang.StackOverflowError
      at com.sun.org.apache.xml.internal.serializer.ToStream.characters(ToStream.java:1457)
      at com.sun.org.apache.xml.internal.serializer.ToHTMLStream.characters(ToHTMLStream.java:1529)
      at com.sun.org.apache.xml.internal.serializer.ToStream.characters(ToStream.java:1613)
      at com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.characters(AbstractTranslet.java:618)
      at junit_frames.br$dash$replace()
      at junit_frames.br$dash$replace()

      1. oom_xalan.txt
        786 kB
        Jochen Stiepel
      2. XALANJ-2526_patch.txt
        0.7 kB
        Jochen Stiepel

        Activity

        Hide
        Michael Glavassevich added a comment -

        The classes in the stack trace are part of Xalan not Xerces-J. Going to transfer this issue over to their JIRA project.

        Show
        Michael Glavassevich added a comment - The classes in the stack trace are part of Xalan not Xerces-J. Going to transfer this issue over to their JIRA project.
        Hide
        Michael Glavassevich added a comment -

        Oh and this isn't even from an Apache release. It's a Sun fork. You need pursue this with Oracle/Sun. We have no influence over what they ship in their JDK.

        Show
        Michael Glavassevich added a comment - Oh and this isn't even from an Apache release. It's a Sun fork. You need pursue this with Oracle/Sun. We have no influence over what they ship in their JDK.
        Hide
        Jochen Stiepel added a comment -

        Junitreport: http://ant.apache.org/manual/Tasks/junitreport.html

        Ant 1.8.1 Junitreport task creates a file TESTS-TestSuites.xml (18 MB) with the result of all junittests. This result file is than used to gether with the junit-frames.xsl to generate the html junit report. For the most junit test runs this works, but for some test run's it doesn't. So it depends on the data inside the TESTS-TestSuites.xml.

        Do you need more information? How can I provide it...

        Show
        Jochen Stiepel added a comment - Junitreport: http://ant.apache.org/manual/Tasks/junitreport.html Ant 1.8.1 Junitreport task creates a file TESTS-TestSuites.xml (18 MB) with the result of all junittests. This result file is than used to gether with the junit-frames.xsl to generate the html junit report. For the most junit test runs this works, but for some test run's it doesn't. So it depends on the data inside the TESTS-TestSuites.xml. Do you need more information? How can I provide it...
        Hide
        Jochen Stiepel added a comment -

        From the jdk sources it is Xalan 2.6.0.

        Show
        Jochen Stiepel added a comment - From the jdk sources it is Xalan 2.6.0.
        Hide
        Jochen Stiepel added a comment - - edited

        Now using Xalan 2.7.1 version I'm getting this error:

        Caused by: Fatal error during transformation
        at org.apache.tools.ant.taskdefs.XSLTProcess.handleTransformationError(XSLTProcess.java:1259)
        at org.apache.tools.ant.taskdefs.XSLTProcess.process(XSLTProcess.java:849)
        at org.apache.tools.ant.taskdefs.XSLTProcess.execute(XSLTProcess.java:386)
        at org.apache.tools.ant.taskdefs.optional.junit.AggregateTransformer.transform(AggregateTransformer.java:264)
        ... 32 more
        Caused by: Fatal error during transformation
        at org.apache.tools.ant.taskdefs.optional.TraXLiaison.fatalError(TraXLiaison.java:517)
        at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1409)
        at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:709)
        at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1273)
        at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1251)
        at org.apache.tools.ant.taskdefs.optional.TraXLiaison.transform(TraXLiaison.java:194)
        at org.apache.tools.ant.taskdefs.XSLTProcess.process(XSLTProcess.java:839)
        ... 34 more
        Caused by: javax.xml.transform.TransformerException: Fatal error during transformation
        at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2405)
        at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2270)
        at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1356)
        ... 39 more
        Caused by: Fatal error during transformation
        at org.apache.tools.ant.taskdefs.optional.TraXLiaison.fatalError(TraXLiaison.java:517)
        at org.apache.xalan.templates.ElemExtensionCall.execute(ElemExtensionCall.java:250)
        at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
        at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
        at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
        ... 41 more
        Caused by: javax.xml.transform.TransformerException: java.lang.StackOverflowError
        at org.apache.xalan.extensions.ExtensionHandlerJavaClass.processElement(ExtensionHandlerJavaClass.java:526)
        at org.apache.xalan.templates.ElemExtensionCall.execute(ElemExtensionCall.java:234)
        ... 44 more
        Caused by: java.lang.StackOverflowError
        at org.apache.xml.serializer.ToStream.characters(ToStream.java:1624)
        at org.apache.xml.serializer.ToHTMLStream.characters(ToHTMLStream.java:1562)
        at org.apache.xml.serializer.ToXMLSAXHandler.characters(ToXMLSAXHandler.java:542)
        at org.apache.xpath.objects.XString.dispatchCharactersEvents(XString.java:206)
        at org.apache.xpath.Expression.executeCharsToContentHandler(Expression.java:315)
        at org.apache.xalan.templates.ElemValueOf.execute(ElemValueOf.java:274)
        at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
        at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:128)
        at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
        at org.apache.xalan.templates.ElemTemplate.execute(ElemTemplate.java:394)
        at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java:248)
        at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
        at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:128)
        at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
        at org.apache.xalan.templates.ElemTemplate.execute(ElemTemplate.java:394)
        at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java:248)
        at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
        at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:128)
        at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
        at org.apache.xalan.templates.ElemTemplate.execute(ElemTemplate.java:394)
        at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java:248)

        Show
        Jochen Stiepel added a comment - - edited Now using Xalan 2.7.1 version I'm getting this error: Caused by: Fatal error during transformation at org.apache.tools.ant.taskdefs.XSLTProcess.handleTransformationError(XSLTProcess.java:1259) at org.apache.tools.ant.taskdefs.XSLTProcess.process(XSLTProcess.java:849) at org.apache.tools.ant.taskdefs.XSLTProcess.execute(XSLTProcess.java:386) at org.apache.tools.ant.taskdefs.optional.junit.AggregateTransformer.transform(AggregateTransformer.java:264) ... 32 more Caused by: Fatal error during transformation at org.apache.tools.ant.taskdefs.optional.TraXLiaison.fatalError(TraXLiaison.java:517) at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1409) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:709) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1273) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1251) at org.apache.tools.ant.taskdefs.optional.TraXLiaison.transform(TraXLiaison.java:194) at org.apache.tools.ant.taskdefs.XSLTProcess.process(XSLTProcess.java:839) ... 34 more Caused by: javax.xml.transform.TransformerException: Fatal error during transformation at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2405) at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2270) at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1356) ... 39 more Caused by: Fatal error during transformation at org.apache.tools.ant.taskdefs.optional.TraXLiaison.fatalError(TraXLiaison.java:517) at org.apache.xalan.templates.ElemExtensionCall.execute(ElemExtensionCall.java:250) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395) at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400) ... 41 more Caused by: javax.xml.transform.TransformerException: java.lang.StackOverflowError at org.apache.xalan.extensions.ExtensionHandlerJavaClass.processElement(ExtensionHandlerJavaClass.java:526) at org.apache.xalan.templates.ElemExtensionCall.execute(ElemExtensionCall.java:234) ... 44 more Caused by: java.lang.StackOverflowError at org.apache.xml.serializer.ToStream.characters(ToStream.java:1624) at org.apache.xml.serializer.ToHTMLStream.characters(ToHTMLStream.java:1562) at org.apache.xml.serializer.ToXMLSAXHandler.characters(ToXMLSAXHandler.java:542) at org.apache.xpath.objects.XString.dispatchCharactersEvents(XString.java:206) at org.apache.xpath.Expression.executeCharsToContentHandler(Expression.java:315) at org.apache.xalan.templates.ElemValueOf.execute(ElemValueOf.java:274) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:128) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400) at org.apache.xalan.templates.ElemTemplate.execute(ElemTemplate.java:394) at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java:248) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:128) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400) at org.apache.xalan.templates.ElemTemplate.execute(ElemTemplate.java:394) at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java:248) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:128) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400) at org.apache.xalan.templates.ElemTemplate.execute(ElemTemplate.java:394) at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java:248)
        Hide
        Jochen Stiepel added a comment -

        now using original Xalan version 2.7.1 (not the JDK Xalan)

        Show
        Jochen Stiepel added a comment - now using original Xalan version 2.7.1 (not the JDK Xalan)
        Hide
        Jochen Stiepel added a comment -

        this affects the jdk xalan 2.6.0 and the normal apache xalan 2.7.1

        Show
        Jochen Stiepel added a comment - this affects the jdk xalan 2.6.0 and the normal apache xalan 2.7.1
        Hide
        Dave Brosius added a comment -

        does defining

        ANT_OPTS=-Xss=1m

        do anything for you?

        Show
        Dave Brosius added a comment - does defining ANT_OPTS=-Xss=1m do anything for you?
        Hide
        Jochen Stiepel added a comment -

        I'm call this ant-task from within maven. So I used

        MAVEN_OPTS= -Xss1m -Xmx2024m -> StackoverflowError, so it doesn't help
        MAVEN_OPTS= -Xss5m -Xmx2548m -> OutOfMemoryError Java Heapspace, the maschine doesn't have more memory.

        Should I analyse the heapdump with eclipse mat ( http://www.eclipse.org/mat/ ) ? Would that be helpfull for you?

        Show
        Jochen Stiepel added a comment - I'm call this ant-task from within maven. So I used MAVEN_OPTS= -Xss1m -Xmx2024m -> StackoverflowError, so it doesn't help MAVEN_OPTS= -Xss5m -Xmx2548m -> OutOfMemoryError Java Heapspace, the maschine doesn't have more memory. Should I analyse the heapdump with eclipse mat ( http://www.eclipse.org/mat/ ) ? Would that be helpfull for you?
        Hide
        Jochen Stiepel added a comment -

        a strackstrace from the place where the outofmemoryerror (OOM) happens

        Show
        Jochen Stiepel added a comment - a strackstrace from the place where the outofmemoryerror (OOM) happens
        Hide
        Jochen Stiepel added a comment -

        This is the cause of the OOM. Eclipse MAT show's that:

        Class Name | Objects | Shallow Heap | Retained Heap
        ---------------------------------------------------------------------------------
        org.apache.xpath.objects.XStringForFSB| 1.147 | 36.704 | >= 1.000.236.904
        ---------------------------------------------------------------------------------

        1.147 Object of type XStringForFSB are using 1000MB of the java heap size.
        Again, the xml file size was 18MB.

        Show
        Jochen Stiepel added a comment - This is the cause of the OOM. Eclipse MAT show's that: Class Name | Objects | Shallow Heap | Retained Heap --------------------------------------------------------------------------------- org.apache.xpath.objects.XStringForFSB| 1.147 | 36.704 | >= 1.000.236.904 --------------------------------------------------------------------------------- 1.147 Object of type XStringForFSB are using 1000MB of the java heap size. Again, the xml file size was 18MB.
        Hide
        Jochen Stiepel added a comment -

        Can I help to resolve this issue?

        This is the dominator tree:

        Class Name | Shallow Heap | Retained Heap | Percentage
        -------------------------------------------------------------------------------------------------------
        java.lang.Thread @ 0x642f06a8 main Thread | 104 | 1.034.776.936 | 99,78%

        • org.apache.xpath.VariableStack @ 0x65da3810
        32 1.000.286.640 96,46%
         
        • org.apache.xpath.objects.XObject[8192] @ 0x65cb91c0
        32.784 1.000.270.208 96,46%
           
        • org.apache.xpath.objects.XStringForFSB @ 0x66548260
        32 980.776 0,09%
           
        • org.apache.xpath.objects.XStringForFSB @ 0x66548280
        32 980.728 0,09%

        ... 1.147 of the XStringForFSB Objects

        -------------------------------------------------------------------------------------------------------

        Show
        Jochen Stiepel added a comment - Can I help to resolve this issue? This is the dominator tree: Class Name | Shallow Heap | Retained Heap | Percentage ------------------------------------------------------------------------------------------------------- java.lang.Thread @ 0x642f06a8 main Thread | 104 | 1.034.776.936 | 99,78% org.apache.xpath.VariableStack @ 0x65da3810 32 1.000.286.640 96,46%   org.apache.xpath.objects.XObject [8192] @ 0x65cb91c0 32.784 1.000.270.208 96,46%     org.apache.xpath.objects.XStringForFSB @ 0x66548260 32 980.776 0,09%     org.apache.xpath.objects.XStringForFSB @ 0x66548280 32 980.728 0,09% ... 1.147 of the XStringForFSB Objects -------------------------------------------------------------------------------------------------------
        Hide
        Jochen Stiepel added a comment - - edited

        Inside the XStringForFSB class almost all of the memory is used for this String
        XStringForFSB.m_strCache

        According to the source:
        http://svn.apache.org/repos/asf/xalan/java/trunk/src/org/apache/xpath/objects/XStringForFSB.java

        this is just a cache. Is it possible to disable this "Cache" String?

        Show
        Jochen Stiepel added a comment - - edited Inside the XStringForFSB class almost all of the memory is used for this String XStringForFSB.m_strCache According to the source: http://svn.apache.org/repos/asf/xalan/java/trunk/src/org/apache/xpath/objects/XStringForFSB.java this is just a cache. Is it possible to disable this "Cache" String?
        Hide
        Dave Brosius added a comment -

        While the memory consumption is concerning, that is not your immediate problem. It is most likely related to how deep your XML is (assuming it isn't just a rogue infinite loop.)

        As unpleasant as it is,I'd keep bumping up the -Xss value.

        Show
        Dave Brosius added a comment - While the memory consumption is concerning, that is not your immediate problem. It is most likely related to how deep your XML is (assuming it isn't just a rogue infinite loop.) As unpleasant as it is,I'd keep bumping up the -Xss value.
        Hide
        Jochen Stiepel added a comment -

        Here is an example of the TESTS-TestSuites.xml file that junitreports generates:
        http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/speedo/speedo/Attic/TESTS-TestSuites.xml?rev=1.1&content-type=text/vnd.viewcvs-markup

        here is a description on what goes on and what's in that TESTS-TestSuites.xml file:
        http://junitpdfreport.sourceforge.net/managedcontent/PdfTranslation

        Show
        Jochen Stiepel added a comment - Here is an example of the TESTS-TestSuites.xml file that junitreports generates: http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/speedo/speedo/Attic/TESTS-TestSuites.xml?rev=1.1&content-type=text/vnd.viewcvs-markup here is a description on what goes on and what's in that TESTS-TestSuites.xml file: http://junitpdfreport.sourceforge.net/managedcontent/PdfTranslation
        Hide
        Jochen Stiepel added a comment -

        disable XStringForFSB.m_strCache

        Show
        Jochen Stiepel added a comment - disable XStringForFSB.m_strCache
        Hide
        Jochen Stiepel added a comment -

        I made the following tests:

        1.) Xalan 2.7.1 with no -Xss option -> Stackoverflowerror
        2.) Xalan 2.7.1 with -Xss1m -> Stackoverflowerror
        3.) Xalan 2.7.1 with -Xss2m -> Stackoverflowerror
        4.) Xalan 2.7.1 with -Xss3m -> Stackoverflowerror
        5.) Xalan 2.7.1 with -Xss4m -> Java OutOfMemoryError with 2500MB Java Heap used.
        6.) Xalan trunk patched with -Xss4m -> Success!! Java Heap Space used 60MB !!! (Monitored with JVisusalVM).

        In the trunk patched version only the XStringForFSB.m_strCache was disabled. I took 4:29 min to process the 18 MB files with the junit-frames.xsl.

        This is a HUGE reduction in Memory (Java Heap Space) consumption!

        Show
        Jochen Stiepel added a comment - I made the following tests: 1.) Xalan 2.7.1 with no -Xss option -> Stackoverflowerror 2.) Xalan 2.7.1 with -Xss1m -> Stackoverflowerror 3.) Xalan 2.7.1 with -Xss2m -> Stackoverflowerror 4.) Xalan 2.7.1 with -Xss3m -> Stackoverflowerror 5.) Xalan 2.7.1 with -Xss4m -> Java OutOfMemoryError with 2500MB Java Heap used. 6.) Xalan trunk patched with -Xss4m -> Success!! Java Heap Space used 60MB !!! (Monitored with JVisusalVM). In the trunk patched version only the XStringForFSB.m_strCache was disabled. I took 4:29 min to process the 18 MB files with the junit-frames.xsl. This is a HUGE reduction in Memory (Java Heap Space) consumption!

          People

          • Assignee:
            Unassigned
            Reporter:
            Jochen Stiepel
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development