Skip to content

8361363: ShenandoahAsserts::print_obj() does not work for forwarded objects and UseCompactObjectHeaders #26117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

tstuefe
Copy link
Member

@tstuefe tstuefe commented Jul 3, 2025

ShenandoahAsserts::print_obj() does not work for COH if the object is forwarded, since the mark word is overwritten with a forwarding pointer.

Depending on the size of the non-null bits of the forwardee (whether it spills into the nKlass bits), nKlass is either zero or garbage. So we get either an "assert(!is_null(v)) failed: narrow klass value can never be zero", or a SIGSEGV.

Fix is trivial: don't use obj->klass() directly but get it from ShenandoahForwarding.


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-8361363: ShenandoahAsserts::print_obj() does not work for forwarded objects and UseCompactObjectHeaders (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26117

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 3, 2025

👋 Welcome back stuefe! 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 Jul 3, 2025

@tstuefe 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:

8361363: ShenandoahAsserts::print_obj() does not work for forwarded objects and UseCompactObjectHeaders

Reviewed-by: rkennke, shade

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 48 new commits pushed to 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 changed the title JDK-8361363: ShenandoahAsserts::print_obj() may not work for forwarded objects and UseCompactObjectHeaders 8361363: ShenandoahAsserts::print_obj() may not work for forwarded objects and UseCompactObjectHeaders Jul 3, 2025
@openjdk
Copy link

openjdk bot commented Jul 3, 2025

@tstuefe 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 hotspot-gc hotspot-gc-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Jul 3, 2025
@tstuefe tstuefe changed the title 8361363: ShenandoahAsserts::print_obj() may not work for forwarded objects and UseCompactObjectHeaders 8361363: ShenandoahAsserts::print_obj() does not work for forwarded objects and UseCompactObjectHeaders Jul 3, 2025
@tstuefe tstuefe marked this pull request as ready for review July 3, 2025 16:54
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 3, 2025
@mlbridge
Copy link

mlbridge bot commented Jul 3, 2025

Webrevs

@tstuefe
Copy link
Member Author

tstuefe commented Jul 8, 2025

Ping @shipilev, maybe? Or @rkennke? Its really trivial.

Copy link
Contributor

@rkennke rkennke left a comment

Choose a reason for hiding this comment

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

Good! Thank you!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 8, 2025
Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

There are two peculiarities in this method. It is normally called from diagnostics code, and so we are not 100% sure it it is even safe to reach through the fwdptr for klass. Second, we should be printing the raw header at least in some cases, because again, diagnostics.

Let me think about it...

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

You know what, this is fine as it is.

The whole business with ShenandoahForwarding::klass is super-duper-awkward, and verifier already touches the forwardees using that method in places where it really should not. It needs a more comprehensive fix for +UCOH.

It is a mess, but not your mess. So integrate this one, we will figure out ShenandoahForwarding::klass after this.

@tstuefe
Copy link
Member Author

tstuefe commented Jul 8, 2025

You know what, this is fine as it is.

The whole business with ShenandoahForwarding::klass is super-duper-awkward, and verifier already touches the forwardees using that method in places where it really should not. It needs a more comprehensive fix for +UCOH.

It is a mess, but not your mess. So integrate this one, we will figure out ShenandoahForwarding::klass after this.

I had a similar thought while working on https://bugs.openjdk.org/browse/JDK-8361342 . ShenandoahForwarding::klass resolves the narrow Klass pointer, which may already assert if that one is null or invalid. I mentally left it for a rainy friday afternoon to fix.

And yes, printing the raw header (and possibly the first few payload words, to get a bit of the first members) I found very useful. os::print_hex_dump will tiptoe around invalid memory, so that should be fine to do.

@tstuefe
Copy link
Member Author

tstuefe commented Jul 9, 2025

Thanks @shipilev and @rkennke !

/integrate

@openjdk
Copy link

openjdk bot commented Jul 9, 2025

Going to push as commit fe26467.
Since your change was applied there have been 62 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 Jul 9, 2025
@openjdk openjdk bot closed this Jul 9, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 9, 2025
@openjdk
Copy link

openjdk bot commented Jul 9, 2025

@tstuefe Pushed as commit fe26467.

💡 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.

3 participants