Skip to content

Commit

Permalink
8290867: Race freeing remembered set segments
Browse files Browse the repository at this point in the history
Reviewed-by: kbarrett, sangheki
  • Loading branch information
Thomas Schatzl committed Aug 3, 2022
1 parent 54c093a commit e265b2a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/hotspot/share/gc/g1/g1SegmentedArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "gc/g1/g1SegmentedArray.inline.hpp"
#include "memory/allocation.hpp"
#include "runtime/atomic.hpp"
#include "runtime/vmOperations.hpp"
#include "utilities/globalCounter.inline.hpp"

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

void G1SegmentedArraySegment::delete_segment(G1SegmentedArraySegment* segment) {
// Wait for concurrent readers of the segment to exit before freeing; but only if the VM
// isn't exiting.
if (!VM_Exit::vm_exited()) {
GlobalCounter::write_synchronize();
}
segment->~G1SegmentedArraySegment();
FREE_C_HEAP_ARRAY(_mem_flag, segment);
}
Expand Down

0 comments on commit e265b2a

Please sign in to comment.