Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7011804

SequenceInputStream with lots of empty substreams can cause StackOverflowError

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 9
    • 6u23
    • core-libs
    • 1.0
    • b06
    • x86
    • windows_7
    • Verified

    Backports

      Description

        FULL PRODUCT VERSION :
        Linux:
        Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
        Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)

        Windows:
        java version "1.6.0_23"
        Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
        Java HotSpot(TM) Client VM (build 19.0-b09, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Linux <name goes here> 2.6.18-194.3.1.el5 #1 SMP Thu May 13 13:08:30 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

        Microsoft Windows [Version 6.1.7600]

        A DESCRIPTION OF THE PROBLEM :
        The SequenceInputStream uses recursion to read additional data when there is more space to fill in the provided buffer.

        In my scenario, I have an Enumeration<FileInputStream> of about 16k files that are all zero bytes of length. I then use the SequenceInputStream#read(byte[], int, int) method to read bytes from the streams.

        Because after each zero-byte read the next stream is retrieved from the Enumeration and then a recursive call to the same read(byte[], int, int) method is done, I get a SOE.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        No SOE.
        ACTUAL -
        2011.01.11 21:22:58 CET FATAL [com.leanapps.life.process.general.jms.JMSProcessQueueBean] - callFinalize: Exception:
        javax.transaction.TransactionRolledbackException: EJB Exception: : java.lang.StackOverflowError
                at java.io.FileInputStream.<init>(FileInputStream.java:66)
                at com.leanapps.life.util.FileUtil$ConcatenatableFiles.nextElement(FileUtil.java:269)
                at com.leanapps.life.util.FileUtil$ConcatenatableFiles.nextElement(FileUtil.java:214)
                at java.io.SequenceInputStream.nextStream(SequenceInputStream.java:93)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:193)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)
                at java.io.SequenceInputStream.read(SequenceInputStream.java:194)

        .. and so on, and so on ...

        REPRODUCIBILITY :
        This bug can be reproduced always.

        Attachments

          Issue Links

            Activity

              People

                igerasim Ivan Gerasimov
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: