RFR [7011804] SequenceInputStream with lots of empty substreams can cause StackOverflowError (original) (raw)

Ivan Gerasimov ivan.gerasimov at oracle.com
Sun Mar 2 11:13:43 UTC 2014


Thank you Alan!

On 02.03.2014 14:50, Alan Bateman wrote:

On 02/03/2014 07:58, Ivan Gerasimov wrote:

Hello!

SequenceInputStream#read functions are implemented recursively. This may cause stack overflow in some extreme cases with lots of empty substreams. Would you please help review the fix? BUGURL: https://bugs.openjdk.java.net/browse/7011804 WEBREV: http://cr.openjdk.java.net/~igerasim/7011804/0/webrev/ Thanks for taking one. I don't think this code has changed much since JDK 1.0 where it seems to have been originally implemented to use recursion. I'm dubious about the bug report and whether the usage is real or made-up to demonstrate the issue. It might also be easier for VM to optimize non-recursive code, if there is such a need.

In any case, the changes good to me. One comment in passing is that normally an InputStream read throws IOException when the stream is closed where as SIS returns EOF. There may be an opportunity to clarify the javadoc in a few places (not for this bug of course).

The test looks okay. I agree with Chris that there shouldn't be a need to run it in its own VM. Ok. I'll remove it.

Sincerely yours, Ivan

-Alan.



More information about the core-libs-dev mailing list