6833576: G1: assert illegal index, growableArray.hpp:186

Tue, 05 May 2009 22:15:35 -0700

author
johnc
date
Tue, 05 May 2009 22:15:35 -0700
changeset 1187
a2957df801a1
parent 1186
20c6f43950b5
child 1188
a58ad611cc63

6833576: G1: assert illegal index, growableArray.hpp:186
Summary: The code that calculates the heap region index for an object address incorrectly used signed arithmetic.
Reviewed-by: jcoomes, ysr

src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp	Thu Apr 30 15:07:53 2009 -0700
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp	Tue May 05 22:15:35 2009 -0700
     1.3 @@ -37,8 +37,9 @@
     1.4  inline HeapRegion*
     1.5  G1CollectedHeap::heap_region_containing_raw(const void* addr) const {
     1.6    assert(_g1_reserved.contains(addr), "invariant");
     1.7 -  size_t index = ((intptr_t) addr - (intptr_t) _g1_reserved.start())
     1.8 -                                              >> HeapRegion::LogOfHRGrainBytes;
     1.9 +  size_t index = pointer_delta(addr, _g1_reserved.start(), 1)
    1.10 +                                        >> HeapRegion::LogOfHRGrainBytes;
    1.11 +
    1.12    HeapRegion* res = _hrs->at(index);
    1.13    assert(res == _hrs->addr_to_region(addr), "sanity");
    1.14    return res;

mercurial