Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8065486 | 8u45 | Ivan Gerasimov | P4 | Resolved | Fixed | b01 |
JDK-8064396 | 8u40 | Ivan Gerasimov | P4 | Resolved | Fixed | b15 |
JDK-8070037 | emb-8u47 | Ivan Gerasimov | P4 | Resolved | Fixed | team |
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
When set Integer.MAX_VALUE - 1 to BitSet, then call the toString method.
It will throw exception: java.lang.IndexOutOfBoundsException: fromIndex < 0: -2147483648
Test code:
public static void main(String[] args) {
BitSet bitSet = new BitSet();
bitSet.set(Integer.MAX_VALUE - 1);
System.out.println( bitSet.toString());
}
The bug was occured at 1189 line of BitSet source.
for (i = nextSetBit(i+1); i >= 0; i = nextSetBit(i+1)) {
If set Integer.MAX_VALUE to BitSet, exception will throw at the first nextSetBit(i+1). If set Integer.MAX_VALUE - 1 to BitSet, exception will throw at the second nextSetBit(i+1).
I think before call nextSetBit(i+1) method, to check i is equal to Integer.MAX_VALUE is better.
REPRODUCIBILITY :
This bug can be reproduced always.
A DESCRIPTION OF THE PROBLEM :
When set Integer.MAX_VALUE - 1 to BitSet, then call the toString method.
It will throw exception: java.lang.IndexOutOfBoundsException: fromIndex < 0: -2147483648
Test code:
public static void main(String[] args) {
BitSet bitSet = new BitSet();
bitSet.set(Integer.MAX_VALUE - 1);
System.out.println( bitSet.toString());
}
The bug was occured at 1189 line of BitSet source.
for (i = nextSetBit(i+1); i >= 0; i = nextSetBit(i+1)) {
If set Integer.MAX_VALUE to BitSet, exception will throw at the first nextSetBit(i+1). If set Integer.MAX_VALUE - 1 to BitSet, exception will throw at the second nextSetBit(i+1).
I think before call nextSetBit(i+1) method, to check i is equal to Integer.MAX_VALUE is better.
REPRODUCIBILITY :
This bug can be reproduced always.
- backported by
-
JDK-8064396 BitSet.toString() can throw IndexOutOfBoundsException
-
- Resolved
-
-
JDK-8065486 BitSet.toString() can throw IndexOutOfBoundsException
-
- Resolved
-
-
JDK-8070037 BitSet.toString() can throw IndexOutOfBoundsException
-
- Resolved
-
- duplicates
-
JDK-8042736 BitSet with Integer.MAX_VALUE as index throws IndexOutOfBoundsException
-
- Closed
-
- relates to
-
JDK-4816253 (spec) BitSet.nextClearBit missing spec for case when index is outside int range
-
- Open
-
-
JDK-8043476 java/util/BitSet/BSMethods.java failed with: java.lang.OutOfMemoryError: Java heap space
-
- Closed
-
(1 relates to)