Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
/ jdk22u Public archive

Commit

Permalink
8323086: Shenandoah: Heap could be corrupted by oom during evacuation
Browse files Browse the repository at this point in the history
Backport-of: c4a83bd6f6c45e72bd776e929005be0aa9408867
  • Loading branch information
William Kemper authored and shipilev committed Jan 10, 2024
1 parent 9e1e6e1 commit 484138e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,27 @@ void ShenandoahDegenGC::op_degenerated() {
// and we can do evacuation. Otherwise, it would be the shortcut cycle.
if (heap->is_evacuation_in_progress()) {

if (_degen_point == _degenerated_evac) {
// Degeneration under oom-evac protocol allows the mutator LRB to expose
// references to from-space objects. This is okay, in theory, because we
// will come to the safepoint here to complete the evacuations and update
// the references. However, if the from-space reference is written to a
// region that was EC during final mark or was recycled after final mark
// it will not have TAMS or UWM updated. Such a region is effectively
// skipped during update references which can lead to crashes and corruption
// if the from-space reference is accessed.
if (UseTLAB) {
heap->labs_make_parsable();
}

for (size_t i = 0; i < heap->num_regions(); i++) {
ShenandoahHeapRegion* r = heap->get_region(i);
if (r->is_active() && r->top() > r->get_update_watermark()) {
r->set_update_watermark_at_safepoint(r->top());
}
}
}

// Degeneration under oom-evac protocol might have left some objects in
// collection set un-evacuated. Restart evacuation from the beginning to
// capture all objects. For all the objects that are already evacuated,
Expand Down

1 comment on commit 484138e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.