Skip to content

8367709: GenShen: Dirty cards for objects that get promoted by safepoint that intervenes between allocation and stores#27832

Closed
earthling-amzn wants to merge 9 commits intoopenjdk:masterfrom
earthling-amzn:fix-not-allocated-young
Closed

8367709: GenShen: Dirty cards for objects that get promoted by safepoint that intervenes between allocation and stores#27832
earthling-amzn wants to merge 9 commits intoopenjdk:masterfrom
earthling-amzn:fix-not-allocated-young

Conversation

@earthling-amzn
Copy link
Contributor

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

I believe this sequence of events can lead to the original assertion failing:

  1. Shenandoah lowers the tenuring threshold to 1.
  2. An object gets allocated on the slow path.
  3. We come to a safepoint and run a degenerated cycle.
  4. The object is evacuated during the degenerated cycle and has its age raised to 1.
  5. The degenerated cycle is "upgraded" to a full GC.
  6. The object is at the tenuring age and gets promoted by the full GC into an old region.
  7. We leave the safepoint and the assertion fails because this "new" object is an old region.

However, there is still a risk that the card marking barriers have been elided for this object. Now that the object is in the old generation we must be sure that if it ends up storing any pointers to young, then these cards must be dirtied. The solution here is conservative in that it just dirties all the cards for this object. We expect this condition to be rare and the card table will refine itself on subsequent GC cycles. Also, note that we will not scan the remembered set without coming to the init-mark safepoint, so it will see these dirty cards.


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-8367709: GenShen: Dirty cards for objects that get promoted by safepoint that intervenes between allocation and stores (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27832

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 15, 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 15, 2025

@earthling-amzn This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8367709: GenShen: Dirty cards for objects that get promoted by safepoint that intervenes between allocation and stores

Reviewed-by: ysr

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 1 new commit pushed to the master branch:

  • a7a3a66: 8354469: Keytool exposes the password in plain text when command is piped using | grep

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added hotspot-gc hotspot-gc-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Oct 15, 2025
@openjdk
Copy link

openjdk bot commented Oct 15, 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.

@earthling-amzn earthling-amzn changed the title GenShen: Dirty cards for objects that get promoted by safepoint that intervenes between allocation and stores 8367709: GenShen: Dirty cards for objects that get promoted by safepoint that intervenes between allocation and stores Oct 15, 2025
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 15, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 15, 2025

Webrevs

);
}
#endif // COMPILER2_OR_JVMCI
assert(thread->deferred_card_mark().is_empty(), "We don't use this");
Copy link
Member

@ysramakrishna ysramakrishna Oct 15, 2025

Choose a reason for hiding this comment

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

This is rare, so probably not worth the extra work, but there is an existing mechanism to defer this until the safepoint (or until another such deferment arises). Not sure if it's worth using it.

Copy link
Member

Choose a reason for hiding this comment

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

Probably not worth the trouble, because that mechanism might require wiring in some other stuff which may not be wired in for GenShen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I thought it looked like a lot of complexity to bring in.

Copy link
Member

Choose a reason for hiding this comment

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

I agree.

Copy link
Member

@ysramakrishna ysramakrishna left a comment

Choose a reason for hiding this comment

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

Good catch of this slippery, if rare, condition. This looks good, but is it possible that we can use a debug *ALot type of flag to manually enlarge the post-allocation window so as to induce this condition (promotion) to happen more frequently in fastdebug runs with the flag enabled? That would exercise this code some.

Copy link
Member

@ysramakrishna ysramakrishna left a comment

Choose a reason for hiding this comment

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

(Left a comment about possibly exercising this code, if easy to do so.) Not a blocking suggestion, though. Approved.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 15, 2025
@earthling-amzn
Copy link
Contributor Author

This condition does happen pretty reliably in the vmTestbase/vm/gc/concurrent/ family of tests mentioned in the ticket.

@earthling-amzn
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Oct 16, 2025

Going to push as commit d447297.
Since your change was applied there have been 26 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Oct 16, 2025
@openjdk openjdk bot closed this Oct 16, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Oct 16, 2025
@openjdk
Copy link

openjdk bot commented Oct 16, 2025

@earthling-amzn Pushed as commit d447297.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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

Labels

hotspot-gc hotspot-gc-dev@openjdk.org integrated Pull request has been integrated shenandoah shenandoah-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

2 participants