[Bug 100017] XML encoder can cause a StackOverflowError

Andrew John Hughes ahughes at redhat.com
Mon Jan 18 11:58:13 PST 2010


On 09:50 Fri 15 Jan     , Joe Wang wrote:
> Thanks Alan. Yes, I did receive the bugzilla notice.
>
> Kelly told me that he applied the same jaxp source tarball to OpenJDK6. 
> Kelly, could you tell Andrew how to include the jaxp source tarball when 
> building OpenJDK6?
>

The tarball jdk6-jaxp-2009_10_27.zip used by the OpenJDK6 build does not
include the fix.  We are still having to apply the patch:

diff -Nru openjdk.orig/jaxp/build.properties openjdk/jaxp/build.properties
--- openjdk.orig/jaxp/build.properties	     2009-12-08 17:42:33.000000000 +0000
+++ openjdk/jaxp/build.properties	     2009-12-08 17:43:03.000000000 +0000
@@ -73,6 +73,9 @@
 # Where patches to drop bundle sources live
 patches.dir=patches
 
+# Patches to apply
+jaxp_src.patch.list=xml-encodinginfo.patch
+
 # Sanity information
 sanity.info= Sanity Settings:${line.separator}\
   ant.home=${ant.home}${line.separator}\
diff -Nru openjdk.orig/jaxp/patches/jaxp_src/xml-encodinginfo.patch openjdk/jaxp/patches/jaxp_src/xml-encodinginfo.patch
--- openjdk.orig/jaxp/patches/jaxp_src/xml-encodinginfo.patch	    1970-01-01 01:00:00.000000000 +0100
+++ openjdk/jaxp/patches/jaxp_src/xml-encodinginfo.patch	    2009-12-08 17:41:58.000000000 +0000
@@ -0,0 +1,18 @@
+diff -Nru src/com/sun/org/apache/xml/internal/serializer/EncodingInfo.java src.new/com/sun/org/apache/xml/internal/serializer/EncodingInfo.java
+--- src/com/sun/org/apache/xml/internal/serializer/EncodingInfo.java	    2009-10-27 21:54:16.000000000 +0000
++++ src.new/com/sun/org/apache/xml/internal/serializer/EncodingInfo.java   2009-12-08 17:40:14.000000000 +0000
+@@ -326,9 +326,11 @@
+             m_last = last;
+ 
+             // Set the range of unicode values that this object
+-            // explicitly manages
+-            m_explFirst = codePoint;
+-            m_explLast = codePoint + (RANGE-1);
++            // explicitly manages. Align the explicitly managed values
++            // to RANGE so multiple EncodingImpl objects dont manage the same 
++            // values.
++            m_explFirst = codePoint / RANGE * RANGE;
++            m_explLast = m_explFirst + (RANGE-1);
+ 
+             m_encoding = encoding;
+ 

BTW, we have a testcase for this.  Would it be possible to add this to
the JDK tree?  The complete patch included in the icedtea6-hg tree
(http://icedtea.classpath.org/people/andrew/icedtea6-hg), including
test case, is attached.

> Thanks,
> Joe
>
>
> Alan Bateman wrote:
>> Joe - I don't know if you get notifications from the bugzilla on 
>> bugs.openjdk.java.net but can you reply to Andrew on this one?
>>
>>
>>
>> bugzilla-daemon at bugs.openjdk.java.net wrote:
>>> https://bugs.openjdk.java.net/show_bug.cgi?id=100017
>>>
>>>
>>> Andrew John Hughes <ahughes at redhat.com> changed:
>>>
>>>            What    |Removed                     |Added
>>> ----------------------------------------------------------------------------
>>>              Status|FIXDELIVERED                |FIXAVAILABLE
>>>          Resolution|FIXED                       |
>>>
>>>
>>>
>>>
>>> --- Comment #7 from Andrew John Hughes <ahughes at redhat.com>  2010-01-15 
>>> 07:32:22 PDT ---
>>> This fix is not yet in OpenJDK6.  When will the JAXP tarballs be updated 
>>> with
>>> this fix?
>>>
>>>   
>>
>

-- 
Andrew :)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
-------------- next part --------------
--- /dev/null	2009-03-12 10:05:36.797002285 -0400
+++ openjdk/jdk/test/com/sun/org/apache/xml/internal/serializer/XMLStackOverflowBug.java	2009-03-13 16:10:05.000000000 -0400
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2009 Red Hat, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary Check that the xml encoder doesnt cause a StackOverflowError
+ *
+ */
+
+import java.io.IOException;
+
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stream.StreamResult;
+
+import org.xml.sax.SAXException;
+
+public class XMLStackOverflowBug {
+
+    public static void main(String[] args)
+            throws TransformerConfigurationException, IOException, SAXException {
+
+        SAXTransformerFactory stf = (SAXTransformerFactory) TransformerFactory
+                .newInstance();
+        TransformerHandler ser = stf.newTransformerHandler();
+        ser.setResult(new StreamResult(System.out));
+
+        StringBuilder sb = new StringBuilder(4096); 
+        for (int x = 4096; x > 0; x--) {
+            sb.append((char)x);
+        }
+        ser.characters(sb.toString().toCharArray(), 0, sb.toString().toCharArray().length);
+        ser.endDocument();
+    }
+}
+
diff -Nru openjdk.orig/jaxp/build.properties openjdk/jaxp/build.properties
--- openjdk.orig/jaxp/build.properties	2009-12-08 17:42:33.000000000 +0000
+++ openjdk/jaxp/build.properties	2009-12-08 17:43:03.000000000 +0000
@@ -73,6 +73,9 @@
 # Where patches to drop bundle sources live
 patches.dir=patches
 
+# Patches to apply
+jaxp_src.patch.list=xml-encodinginfo.patch
+
 # Sanity information
 sanity.info= Sanity Settings:${line.separator}\
   ant.home=${ant.home}${line.separator}\
diff -Nru openjdk.orig/jaxp/patches/jaxp_src/xml-encodinginfo.patch openjdk/jaxp/patches/jaxp_src/xml-encodinginfo.patch
--- openjdk.orig/jaxp/patches/jaxp_src/xml-encodinginfo.patch	1970-01-01 01:00:00.000000000 +0100
+++ openjdk/jaxp/patches/jaxp_src/xml-encodinginfo.patch	2009-12-08 17:41:58.000000000 +0000
@@ -0,0 +1,18 @@
+diff -Nru src/com/sun/org/apache/xml/internal/serializer/EncodingInfo.java src.new/com/sun/org/apache/xml/internal/serializer/EncodingInfo.java
+--- src/com/sun/org/apache/xml/internal/serializer/EncodingInfo.java	2009-10-27 21:54:16.000000000 +0000
++++ src.new/com/sun/org/apache/xml/internal/serializer/EncodingInfo.java	2009-12-08 17:40:14.000000000 +0000
+@@ -326,9 +326,11 @@
+             m_last = last;
+ 
+             // Set the range of unicode values that this object
+-            // explicitly manages
+-            m_explFirst = codePoint;
+-            m_explLast = codePoint + (RANGE-1);
++            // explicitly manages. Align the explicitly managed values
++            // to RANGE so multiple EncodingImpl objects dont manage the same 
++            // values.
++            m_explFirst = codePoint / RANGE * RANGE;
++            m_explLast = m_explFirst + (RANGE-1);
+ 
+             m_encoding = encoding;
+ 


More information about the jdk6-dev mailing list