Skip to content

Conversation

earthling-amzn
Copy link
Contributor

@earthling-amzn earthling-amzn commented Oct 6, 2025

I believe the following events could lead to this assertion failure:

  1. Control thread reads the heap's gc cancellation cause as shenandoah_concurrent_gc
  2. Mutator thread has an allocation failure and sets the heap's gc cancellation cause to shenandoah_alloc_failure
  3. Control thread uses stale value from 1 and decides to unconditionally clear the cancellation cause
  4. Mutator thread assert that gc is still cancelled

The proposed fix here has the control thread use a CAS operation to only clear the gc if the existing value is shenandoah_concurrent_gc. This will stop the control thread from erroneously changing the value if a mutator has already set it to shenandoah_alloc_failure. A mutator thread may still have an allocation failure after the control thread has cleared the cancellation, but this is normal and expected.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8367646: [GenShen] Control thread may overwrite gc cancellation cause set by mutator (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27662/head:pull/27662
$ git checkout pull/27662

Update a local copy of the PR:
$ git checkout pull/27662
$ git pull https://git.openjdk.org/jdk.git pull/27662/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27662

View PR using the GUI difftool:
$ git pr show -t 27662

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27662.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 6, 2025

👋 Welcome back wkemper! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 6, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Oct 6, 2025

@earthling-amzn The following labels will be automatically applied to this pull request:

  • hotspot-gc
  • shenandoah

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 6, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 6, 2025

Webrevs

Copy link
Contributor

@kdnilsen kdnilsen left a comment

Choose a reason for hiding this comment

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

There's a typo in description of the issue: s/if/is/

Have we been able to confirm through testing that this resolves the previously observed assertion failure?

@earthling-amzn
Copy link
Contributor Author

I was never able to reproduce it. The crash was observed on somewhat exotic hardware. I'm fairly confident in the fix because in all other cases the cancellation cause is only cleared on a safepoint. That is to say, this code is the only place the collector clears the cancellation cause concurrently with mutators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants