Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-2439

[PATCH] XSLTC resource leak causes 'No more DTM IDs are available' error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • The Latest Development Code
    • XSLTC
    • None
    • Linux and Windows XP with Sun JRE 1.5.0_15 and 1.6.0_05
    • PatchAvailable

    Description

      The Xalan XSLT compiler (XSLTC) has several resource leaks in handling
      result tree fragments in XSLT variables and parameters. If a variable
      or parameter declaration contains XML elements, a new DOM tree is created
      and a new internal integer id is reserved for it. The garbage collector can
      never retrieve this DOM tree, because the id registration holds a reference
      to it. This bug prevents the transformation of large input files, because
      complex templates creates many result tree fragments and exceeds often the
      absolute limit of possible DOM trees in XSLTC (2^16 = 65535). If this
      limit is reached, XSLTC throws the following exception:

      DTMException: No more DTM IDs are available

      The attached patch adds a new release method to the DOM interface and calls
      it, when the scope of a variable or parameter is leaved.

      You can test this patch with the attached JAR file. This file can be
      called with

      java -Xmx800M -jar DOMLeak-XSLT-Test-X.Y.jar

      This file contains four test style sheets with expected output files.

      This bug exists also in all Sun JRE 1.5 and 1.6 versions, because the
      Xalan XSLTC source code is used in the 'com.sun.org.apache.xalan.internal'
      packages. The attached test JAR file contains also a patch for the current
      Sun JRE version 1.6.0_5 and a fix JAR file to be installed into the
      '../jre/lib/endorsed' directory of the JRE installation.

      Please add the attached test files to the Xalan test suite. I have
      released them under Apache license version 2.0.

      Helge Schulz - http://OpenSHORE.org

      ----------
      Here is the output of running my test cases with several Java version:

      test:
      apply-with-all-versions:
      [apply] Buildfile: build.xml
      [apply] test-java:
      [apply] [echo] Test Sun Java 1.4.2_17 with integrated XSLT
      [apply] [java] Testing DOMLeak-1-ResultTreeInVariable.xsl... Ok.
      [apply] [java] Testing DOMLeak-2-ResultTreeInCallParameter.xsl... Ok.
      [apply] [java] Testing DOMLeak-3-ResultTreeInApplyParameter.xsl... Ok.
      [apply] [java] Testing DOMLeak-4-NodeSetAndMultiDOM.xsl... Ok.
      [apply] [echo]
      [apply] [echo] Test Sun Java 1.4.2_17 with latest Xalan (SVN revision 584164)
      [apply] [java] Testing DOMLeak-1-ResultTreeInVariable.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: org.apache.xml.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-2-ResultTreeInCallParameter.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: org.apache.xml.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-3-ResultTreeInApplyParameter.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: org.apache.xml.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-4-NodeSetAndMultiDOM.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: org.apache.xml.dtm.DTMException: No more DTM IDs are available
      [apply] [echo]
      [apply] [echo] Test Sun Java 1.4.2_17 with fixed Xalan
      [apply] [java] Testing DOMLeak-1-ResultTreeInVariable.xsl... Ok.
      [apply] [java] Testing DOMLeak-2-ResultTreeInCallParameter.xsl... Ok.
      [apply] [java] Testing DOMLeak-3-ResultTreeInApplyParameter.xsl... Ok.
      [apply] [java] Testing DOMLeak-4-NodeSetAndMultiDOM.xsl... Ok.
      [apply] BUILD SUCCESSFUL
      [apply] Total time: 1 minute 21 seconds
      [apply] Buildfile: build.xml
      [apply] test-java:
      [apply] [echo] Test Sun Java 1.5.0_15 with integrated XSLT
      [apply] [java] Testing DOMLeak-1-ResultTreeInVariable.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: com.sun.org.apache.xml.internal.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-2-ResultTreeInCallParameter.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: com.sun.org.apache.xml.internal.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-3-ResultTreeInApplyParameter.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: com.sun.org.apache.xml.internal.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-4-NodeSetAndMultiDOM.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: com.sun.org.apache.xml.internal.dtm.DTMException: No more DTM IDs are available
      [apply] [echo]
      [apply] [echo] Test Sun Java 1.5.0_15 with latest Xalan (SVN revision 584164)
      [apply] [java] Testing DOMLeak-1-ResultTreeInVariable.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: org.apache.xml.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-2-ResultTreeInCallParameter.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: org.apache.xml.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-3-ResultTreeInApplyParameter.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: org.apache.xml.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-4-NodeSetAndMultiDOM.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: org.apache.xml.dtm.DTMException: No more DTM IDs are available
      [apply] [echo]
      [apply] [echo] Test Sun Java 1.5.0_15 with fixed Xalan
      [apply] [java] Testing DOMLeak-1-ResultTreeInVariable.xsl... Ok.
      [apply] [java] Testing DOMLeak-2-ResultTreeInCallParameter.xsl... Ok.
      [apply] [java] Testing DOMLeak-3-ResultTreeInApplyParameter.xsl... Ok.
      [apply] [java] Testing DOMLeak-4-NodeSetAndMultiDOM.xsl... Ok.
      [apply] BUILD SUCCESSFUL
      [apply] Total time: 2 minutes 13 seconds
      [apply] Buildfile: build.xml
      [apply] test-java:
      [apply] [echo] Test Sun Java 1.6.0_05 with integrated XSLT
      [apply] [java] Testing DOMLeak-1-ResultTreeInVariable.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: com.sun.org.apache.xml.internal.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-2-ResultTreeInCallParameter.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: com.sun.org.apache.xml.internal.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-3-ResultTreeInApplyParameter.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: com.sun.org.apache.xml.internal.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-4-NodeSetAndMultiDOM.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: com.sun.org.apache.xml.internal.dtm.DTMException: No more DTM IDs are available
      [apply] [echo]
      [apply] [echo] Test Sun Java 1.6.0_05 with latest Xalan (SVN revision 584164)
      [apply] [java] Testing DOMLeak-1-ResultTreeInVariable.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: org.apache.xml.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-2-ResultTreeInCallParameter.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: org.apache.xml.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-3-ResultTreeInApplyParameter.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: org.apache.xml.dtm.DTMException: No more DTM IDs are available
      [apply] [java] Testing DOMLeak-4-NodeSetAndMultiDOM.xsl... ERROR: 'No more DTM IDs are available'
      [apply] [java] XSLT Exception: org.apache.xml.dtm.DTMException: No more DTM IDs are available
      [apply] [echo]
      [apply] [echo] Test Sun Java 1.6.0_05 with fixed Xalan
      [apply] [java] Testing DOMLeak-1-ResultTreeInVariable.xsl... Ok.
      [apply] [java] Testing DOMLeak-2-ResultTreeInCallParameter.xsl... Ok.
      [apply] [java] Testing DOMLeak-3-ResultTreeInApplyParameter.xsl... Ok.
      [apply] [java] Testing DOMLeak-4-NodeSetAndMultiDOM.xsl... Ok.
      [apply] BUILD SUCCESSFUL
      [apply] Total time: 1 minute 42 seconds
      BUILD SUCCESSFUL
      Total time: 5 minutes 22 seconds

      Attachments

        1. DOMLeak-Xalan-SVN-r584164.patch
          13 kB
          Helge Schulz
        2. DOMLeak-4-NodeSetAndMultiDOM.xsl
          2 kB
          Helge Schulz
        3. DOMLeak-XSLT-Test-1.0.jar
          19 kB
          Helge Schulz

        Activity

          People

            Unassigned Unassigned
            heschulz Helge Schulz
            Votes:
            4 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 4h
                4h
                Remaining:
                Remaining Estimate - 4h
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified