Skip to content

Commit 685c03d

Browse files
author
Kim Barrett
committedJan 22, 2021
8259271: gc/parallel/TestDynShrinkHeap.java still fails "assert(covered_region.contains(new_memregion)) failed: new region is not in covered_region"
Use load_acquire to order reads of top and end. Reviewed-by: tschatzl, iwalulya, eosterlund
1 parent d90e06a commit 685c03d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/hotspot/share/gc/parallel/mutableSpace.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ HeapWord* MutableSpace::allocate(size_t size) {
194194
// This version is lock-free.
195195
HeapWord* MutableSpace::cas_allocate(size_t size) {
196196
do {
197-
HeapWord* obj = top();
197+
// Read top before end, else the range check may pass when it shouldn't.
198+
// If end is read first, other threads may advance end and top such that
199+
// current top > old end and current top + size > current end. Then
200+
// pointer_delta underflows, allowing installation of top > current end.
201+
HeapWord* obj = Atomic::load_acquire(top_addr());
198202
if (pointer_delta(end(), obj) >= size) {
199203
HeapWord* new_top = obj + size;
200204
HeapWord* result = Atomic::cmpxchg(top_addr(), obj, new_top);

0 commit comments

Comments
 (0)
Please sign in to comment.