FULL PRODUCT VERSION :
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b65)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b65, mixed mode)
FULL OS VERSION :
Checked on Windows and Linux, 64-bit. Same behavior.
A DESCRIPTION OF THE PROBLEM :
Expected behavior:
The code re-reads a valid bz2 resource, looping and printing (infinitely):
Round...
Round...
Round...
Actual behavior (64-Bit Server VM, build 1.9.0-ea-b64, mixed mode):
Round...
Round...
Round...
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 314297
at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.setupBlock(BZip2CompressorInputStream.java:820)
Definitely something with the compilation because disabling loop
unrolling (or running in interpreted mode) doesn't trigger the bug.
THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No
THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes
REGRESSION. Last worked in version 8u45
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The bug repro code is at the link below:
http://download.carrotsearch.com/jvm/repro.zip
- Self contained maven project (copied commons compress sources so that one can
tweak them if needed). An additional bz2 resource is needed (included).
- (optionally) build with:
mvn package
- Run with:
java -jar target/Repro-0.0.0.jar
- Running in interpreted mode does *not* cause any error:
java -Xint -jar target/Repro-0.0.0.jar
- Running without loop unrolls does *not* cause any error:
java -Xbatch -XX:LoopUnrollLimit=0 -jar target/Repro-0.0.0.jar
EXPECTED VERSUS ACTUAL BEHAVIOR :
The program should run without AIOOBs, the input is valid.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 314297
at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.setupBlock(BZip2CompressorInputStream.java:820)
(the index does vary from run to run).
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Source code in the ZIP link pasted above (not a trivial snippet).
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Disable loop unrolling. Run in interpreted mode.