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

Commit e265b2a

Browse files
author
Thomas Schatzl
committed
8290867: Race freeing remembered set segments
Reviewed-by: kbarrett, sangheki
1 parent 54c093a commit e265b2a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/hotspot/share/gc/g1/g1SegmentedArray.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "gc/g1/g1SegmentedArray.inline.hpp"
2828
#include "memory/allocation.hpp"
2929
#include "runtime/atomic.hpp"
30+
#include "runtime/vmOperations.hpp"
3031
#include "utilities/globalCounter.inline.hpp"
3132

3233
G1SegmentedArraySegment::G1SegmentedArraySegment(uint slot_size, uint num_slots, G1SegmentedArraySegment* next, MEMFLAGS flag) :
@@ -48,6 +49,11 @@ G1SegmentedArraySegment* G1SegmentedArraySegment::create_segment(uint slot_size,
4849
}
4950

5051
void G1SegmentedArraySegment::delete_segment(G1SegmentedArraySegment* segment) {
52+
// Wait for concurrent readers of the segment to exit before freeing; but only if the VM
53+
// isn't exiting.
54+
if (!VM_Exit::vm_exited()) {
55+
GlobalCounter::write_synchronize();
56+
}
5157
segment->~G1SegmentedArraySegment();
5258
FREE_C_HEAP_ARRAY(_mem_flag, segment);
5359
}

0 commit comments

Comments
 (0)