Details
-
Bug
-
Resolution: Fixed
-
P3
-
6u29, 8
-
b106
-
x86
-
windows_2008
-
Verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8023728 | 7-pool | Ivan Gerasimov | P3 | Closed | Won't Fix | |
JDK-8023729 | 6-pool | Ivan Gerasimov | P3 | Closed | Won't Fix |
Description
FULL PRODUCT VERSION :
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
There is an issue with the BufferedInputStream when used with large inputstreams and using mark where the fill() method will calculate a negative size and throw a NegativeArraySizeException
java.lang.NegativeArraySizeException
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source).
REGRESSION. Last worked in version 6u29
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Open a large inputstream such as a file. ( My repro used a 3600 MB file)
2. Use a buffered inputstream to read the file
3. call mark
4. Copy the entire stream to another outputstream
exception will be thrown in BufferedInputStream.fill()
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
File copy works correctly.
ACTUAL -
java.lang.NegativeArraySizeException
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NegativeArraySizeException
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
// Note my input file was 3.6 Gbs for this repro.
InputStream buffStream = new BufferedInputStream(new FileInputStream(f));
FileOutputStream outStream = new FileOutputStream(other);
// Mark sourceStream for current position.
buffStream.mark(Integer.MAX_VALUE);
try {
int count = -1;
long total = 0;
final byte[] retrievedBuff = new byte[8 * 1024];
count = buffStream.read(retrievedBuff, 0, 8 * 1024);
while (count != -1) {
outStream.write(retrievedBuff, 0, count);
total += count;
count = buffStream.read(retrievedBuff, 0, 8 * 1024);
}
} catch (Exception e) {
e.printStackTrace();
}
buffStream.close();
outStream.close();
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Dont use BufferedInputStream :)
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
There is an issue with the BufferedInputStream when used with large inputstreams and using mark where the fill() method will calculate a negative size and throw a NegativeArraySizeException
java.lang.NegativeArraySizeException
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source).
REGRESSION. Last worked in version 6u29
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Open a large inputstream such as a file. ( My repro used a 3600 MB file)
2. Use a buffered inputstream to read the file
3. call mark
4. Copy the entire stream to another outputstream
exception will be thrown in BufferedInputStream.fill()
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
File copy works correctly.
ACTUAL -
java.lang.NegativeArraySizeException
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NegativeArraySizeException
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
// Note my input file was 3.6 Gbs for this repro.
InputStream buffStream = new BufferedInputStream(new FileInputStream(f));
FileOutputStream outStream = new FileOutputStream(other);
// Mark sourceStream for current position.
buffStream.mark(Integer.MAX_VALUE);
try {
int count = -1;
long total = 0;
final byte[] retrievedBuff = new byte[8 * 1024];
count = buffStream.read(retrievedBuff, 0, 8 * 1024);
while (count != -1) {
outStream.write(retrievedBuff, 0, count);
total += count;
count = buffStream.read(retrievedBuff, 0, 8 * 1024);
}
} catch (Exception e) {
e.printStackTrace();
}
buffStream.close();
outStream.close();
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Dont use BufferedInputStream :)
Attachments
Issue Links
- backported by
-
JDK-8023728 BufferedInputStream calculates negative array size with large streams and mark
- Closed
-
JDK-8023729 BufferedInputStream calculates negative array size with large streams and mark
- Closed