Hi, I ran across an issue where the xml encoder would cause a StackOverflowError. The original bug report is at [1]. Since com.sun.org.apache.xml.internal.serializer.EncodingInfo.EncodingImpl [2] is based on org.apache.xml.serializer.EncodingInfo.EncodingImpl, I thought this might be an appropriate place to ask for feedback on the proposed patch.
The issue appears to be this: When finding the encoding for (char) 4096, an EncodingImpl object is created which explicitly manages characters 4096 to 4223. So far so good. But when the transformer tries to find the encoding for (char) 4095, a new EncodingImpl delegate object is created which manages the values 4095 to 4222. Effectively, this object only manages the value 4095 (since the parent already manages 4096 to 4222). Do this a few more times, and you have one stack frame for each value. Trying to encode characters from 0xffff to 0x0000 will result in thousands of stack frames. The proposed patch makes sure that each delegate manages 128 values which dont overlap with any other delegate. The patch brings down the maximum number of delegates in the chain to (0xffff + 1)/RANGE = 512 (also the max number of stack frames that can be used by EndcodingImpl). Cheers, Omair [1] http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=295 [2] http://icedtea.classpath.org/hg/openjdk6/file/356b40e3410a/jaxp/src/share/classes/com/sun/org/apache/xml/internal/serializer/EncodingInfo.java
--- EncodingInfo.java.orig 2009-02-19 14:46:50.000000000 -0500 +++ EncodingInfo.java 2009-02-20 10:31:37.000000000 -0500 @@ -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;
--------------------------------------------------------------------- To unsubscribe, e-mail: xalan-dev-unsubscr...@xml.apache.org For additional commands, e-mail: xalan-dev-h...@xml.apache.org