Skip to content

Conversation

@anton-seoane
Copy link
Contributor

@anton-seoane anton-seoane commented Oct 21, 2025

This PR introduces a fix for a intermittent assert crash due to a non-oop found in the stack when deoptimizing.

The inline_native_GetEventWriter JFR intrinsic performs a call into the runtime, which can safepoint, to write a checkpoint for the vthread. This call returns a global handle (jobject) that then gets resolved to a raw oop.

However, the corresponding jfr_write_checkpoint_Type does not set any return, modelling the call as void. If a safepoint hits in the small window after the stub returns but before the writer oop is used, and the GC moves the object in that window, the deoptimization path cannot resolve a handle that it never recorded, leading to the subsequent crash.

An IR Framework test is introduced to exercise the error explicitly. Additionally, related documentation in form of comments in the appropriate file (runtime.hpp) is added to hopefully prevent similar cases in the future.

Testing: passes tiers 1-5


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-8347463: jdk/jfr/threading/TestManyVirtualThreads.java crashes with assert(oopDesc::is_oop_or_null(val)) (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27913

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 21, 2025

👋 Welcome back aseoane! 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 21, 2025

@anton-seoane 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:

8347463: jdk/jfr/threading/TestManyVirtualThreads.java crashes with  assert(oopDesc::is_oop_or_null(val))

Reviewed-by: dlong, rcastanedalo, mgronlun

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

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@robcasloz, @mgronlun, @dean-long) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot changed the title 8347463: jdk/jfr/threading/TestManyVirtualThreads.java crashes with assert(oopDesc::is_oop_or_null(val)) 8347463: jdk/jfr/threading/TestManyVirtualThreads.java crashes with assert(oopDesc::is_oop_or_null(val)) Oct 21, 2025
@openjdk
Copy link

openjdk bot commented Oct 21, 2025

@anton-seoane The following label will be automatically applied to this pull request:

  • hotspot-compiler

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

@anton-seoane anton-seoane marked this pull request as ready for review October 21, 2025 09:25
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 21, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 21, 2025

@robcasloz
Copy link
Contributor

/cc hotspot-jfr

@openjdk
Copy link

openjdk bot commented Oct 21, 2025

@robcasloz
The hotspot-jfr label was successfully added.

@anton-seoane anton-seoane marked this pull request as draft October 21, 2025 13:00
@anton-seoane
Copy link
Contributor Author

Switching back to draft after conversation with @robcasloz, to perform further investigation

@openjdk openjdk bot removed the rfr Pull request is ready for review label Oct 21, 2025
@openjdk
Copy link

openjdk bot commented Oct 23, 2025

⚠️ @anton-seoane This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

@openjdk
Copy link

openjdk bot commented Oct 23, 2025

@anton-seoane hotspot has been added to this pull request based on files touched in new commit(s).

@anton-seoane anton-seoane marked this pull request as ready for review October 27, 2025 06:31
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 27, 2025
Copy link
Contributor

@robcasloz robcasloz left a comment

Choose a reason for hiding this comment

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

Thanks for getting to the bottom of this, Antón! The changeset looks good to me, modulo a few documentation and test comments.
It would be good if someone from the JFR team (@mgronlun or @egahlin?) could have a look at this change as well.

* @test
* @summary Tests that the getEventWriter call to write_checkpoint correctly
* reports returning an oop
* @requires vm.hasJFR & vm.continuations
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need vm.continuations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't. Removed the requirement

* reports returning an oop
* @requires vm.hasJFR & vm.continuations
* @library /test/lib /
* @modules jdk.jfr/jdk.jfr.internal
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't. Removed as well!

Copy link
Contributor

Choose a reason for hiding this comment

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

(Referring to line 38 only).

Copy link
Contributor

@robcasloz robcasloz left a comment

Choose a reason for hiding this comment

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

Thanks! Please test the latest changes, at least through some low tiers, before integration.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 27, 2025
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Oct 27, 2025
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 27, 2025
@anton-seoane
Copy link
Contributor Author

anton-seoane commented Oct 27, 2025

Reverted the more precise IR Framework check that @robcasloz suggested as the method where the actual call to write_checkpoint happened was not always being inlined, resulting in a failure. I am back to the original check for a non-void return type. Quick check shows no issues (ran tiers 1-3)

TestFramework.run();
}

// Crash was due to the returns_oop field not being set
Copy link
Member

Choose a reason for hiding this comment

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

I was confused when I could not find "returns_oop". It turns out the names are CallNode::returns_pointer() and ScopeDesc::return_oop().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I got them mixed up. I will update things accordingly, thanks!

// Please ensure the return type of the runtime call matches its signature,
// even if the return value is unused. This is crucial for correct handling
// of runtime calls that return an oop and may trigger deoptimization
// on return. See rematerialize_objects() in deoptimization.cpp.
Copy link
Member

Choose a reason for hiding this comment

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

I was wondering why this is only a problem for deoptimization, and not regular safepoints that trigger a GC. But the comment in rematerialize_objects() explains that the return value is not part of the GC oopmap.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Oct 28, 2025
* @bug 8347463
* @requires vm.hasJFR
* @library /test/lib /
* @run driver compiler.intrinsics.TestReturnsOopSetForJFRWriteCheckpoint
Copy link
Contributor

Choose a reason for hiding this comment

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

You will have to update this line as well after the class name change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, right. My bad. Fixed

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 29, 2025
@anton-seoane
Copy link
Contributor Author

Thanks to all for the reviews and suggestions!

@anton-seoane
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Oct 29, 2025
@openjdk
Copy link

openjdk bot commented Oct 29, 2025

@anton-seoane
Your change (at version 72202ad) is now ready to be sponsored by a Committer.

@robcasloz
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Oct 29, 2025

Going to push as commit 8457f38.
Since your change was applied there have been 70 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 29, 2025
@openjdk openjdk bot closed this Oct 29, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Oct 29, 2025
@openjdk
Copy link

openjdk bot commented Oct 29, 2025

@robcasloz @anton-seoane Pushed as commit 8457f38.

💡 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

Development

Successfully merging this pull request may close these issues.

4 participants