Skip to content

Commit

Permalink
8323086: Shenandoah: Heap could be corrupted by oom during evacuation
Browse files Browse the repository at this point in the history
Reviewed-by: kdnilsen, shade
  • Loading branch information
William Kemper authored and shipilev committed Jan 8, 2024
1 parent 827c71d commit c4a83bd
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

7 comments on commit c4a83bd

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@earthling-amzn
Copy link
Contributor

Choose a reason for hiding this comment

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

/backport jdk22u

@earthling-amzn
Copy link
Contributor

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@earthling-amzn
Copy link
Contributor

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on c4a83bd Jan 8, 2024

Choose a reason for hiding this comment

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

@earthling-amzn the backport was successfully created on the branch backport-earthling-amzn-c4a83bd6 in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit c4a83bd6 from the openjdk/jdk repository.

The commit being backported was authored by William Kemper on 8 Jan 2024 and was reviewed by Kelvin Nilsen and Aleksey Shipilev.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-earthling-amzn-c4a83bd6:backport-earthling-amzn-c4a83bd6
$ git checkout backport-earthling-amzn-c4a83bd6
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-earthling-amzn-c4a83bd6

@openjdk
Copy link

@openjdk openjdk bot commented on c4a83bd Jan 8, 2024

Choose a reason for hiding this comment

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

@earthling-amzn the backport was successfully created on the branch backport-earthling-amzn-c4a83bd6 in my personal fork of openjdk/jdk22u. To create a pull request with this backport targeting openjdk/jdk22u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit c4a83bd6 from the openjdk/jdk repository.

The commit being backported was authored by William Kemper on 8 Jan 2024 and was reviewed by Kelvin Nilsen and Aleksey Shipilev.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk22u:

$ git fetch https://github.com/openjdk-bots/jdk22u.git backport-earthling-amzn-c4a83bd6:backport-earthling-amzn-c4a83bd6
$ git checkout backport-earthling-amzn-c4a83bd6
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk22u.git backport-earthling-amzn-c4a83bd6

@openjdk
Copy link

@openjdk openjdk bot commented on c4a83bd Jan 8, 2024

Choose a reason for hiding this comment

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

@earthling-amzn the backport was successfully created on the branch backport-earthling-amzn-c4a83bd6 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit c4a83bd6 from the openjdk/jdk repository.

The commit being backported was authored by William Kemper on 8 Jan 2024 and was reviewed by Kelvin Nilsen and Aleksey Shipilev.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git backport-earthling-amzn-c4a83bd6:backport-earthling-amzn-c4a83bd6
$ git checkout backport-earthling-amzn-c4a83bd6
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git backport-earthling-amzn-c4a83bd6

Please sign in to comment.