Request for review: 7110152 assert(size_in_words <= (julong)max_jint) failed: no overflow
Bengt Rutisson
bengt.rutisson at oracle.com
Wed Nov 9 21:34:15 UTC 2011
Hi all,
Could I have a couple of reviews for this small change?
http://cr.openjdk.java.net/~brutisso/7110152/webrev.01/
The problem is that CollectedHeap::array_allocate() takes its size as an
int instead of a size_t. This was exposed by the fix I made to 7102044
recently.
That change allows arrays to be max_jint long on 64 bit systems. This is
correct since we can handle this size in a 64 bit size_t even when we
add the object header. However, it will overflow an int.
Here is a small reproducer that will trigger the assert mentioned in
7110152 when it is run on a 64 bit VM:
public class MaxJIntArray {
public static void main(String[] args) {
final int MAX_JINT = 2147483647;
double[] a = new double[MAX_JINT];
System.out.println("Allocated a[" + a.length + "]");
}
}
The fix is to remove the assert (since it is too strict) and changing
CollectedHeap::array_allocate() to take a size_t instead of an int.
CR:
7110152 assert(size_in_words <= (julong)max_jint) failed: no overflow
http://monaco.sfbay.sun.com/detail.jsf?cr=7110152
Bengt
More information about the hotspot-gc-dev
mailing list