Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 7ac9247

Browse files
Olga MikhaltsovaYuri Nesterenko
authored andcommitted
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. Backport-of: 685c03dc4899e4f43e830d516b751969ed20ec21
1 parent d5d9b45 commit 7ac9247

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

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

0 commit comments

Comments
 (0)