RFR (XS): 8182050: assert(_whole_heap.contains(p)) failed: Attempt to access p out of bounds of card marking array's _whole_heap

Thomas Schatzl thomas.schatzl at oracle.com
Wed Nov 22 13:18:15 UTC 2017

Hi all,

  can I have reviews for this tiny change that fixes tripping an assert
when executing the post barrier for arrays for G1?

The issue is that when calling arraycopy to a zero sized array of j.l.O
a call to the post barrier is emitted. If that object at that point has
 been allocated so that its non-existent value array is located at the
end of the heap, the MemRegion passed to
G1SATBCardTableLoggingModRefBS::invalidate() has a start address just
beyond the heap the assert trips over (it has a zero-sized length).

Note that the G1 invalidation code is correct, i.e. handled the
situation correctly, just the assert is wrong in this case.

The suggested fix is to ignore zero-sized MemRegions like the other
card table implementation does. This will keep triggering the assert
for really wrong MemRegions (which is desired imho).

Thanks go to Alex who investigated and fixed a very similar issue with
the other collectors in JDK-8185591.

Included jtreg test case, checking that the issue does not occur with
the change anymore.


More information about the hotspot-gc-dev mailing list