Skip to content
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

8331735: UpcallLinker::on_exit races with GC when copying frame anchor #3434

Closed
wants to merge 1 commit into from

Conversation

gnu-andrew
Copy link
Member

@gnu-andrew gnu-andrew commented Apr 3, 2025

Partial backport of a fix for a race condition in code adapted from JavaCallWrapper for the FFM API. This is more visible in 22 and later, where FFM is fully supported and the OpenType implementation using HarfBuzz has been ported to use it.

However, the copy in the native state seems to have been introduced as far back as JDK-8269240 in 17 when the JavaCallWrapper code was ported to what was then universalUpcallHandler.cpp. That fix to ::on_exit is included here.

The other hunk in the 24 and 21u versions is omitted as the ::on_entry method has not been modified by JDK-8272526 which is what moved the thread exception handling to native code.


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
  • JDK-8286875 needs maintainer approval
  • JDK-8331735 needs maintainer approval

Issues

  • JDK-8331735: UpcallLinker::on_exit races with GC when copying frame anchor (Bug - P3 - Approved)
  • JDK-8286875: ProgrammableUpcallHandler::on_entry/on_exit access thread fields from native (Bug - P4 - Approved)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk17u-dev.git pull/3434/head:pull/3434
$ git checkout pull/3434

Update a local copy of the PR:
$ git checkout pull/3434
$ git pull https://git.openjdk.org/jdk17u-dev.git pull/3434/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3434

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk17u-dev/pull/3434.diff

Using Webrev

Link to Webrev Comment

Sorry, something went wrong.

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 3, 2025

👋 Welcome back andrew! 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 Apr 3, 2025

@gnu-andrew 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:

8331735: UpcallLinker::on_exit races with GC when copying frame anchor
8286875: ProgrammableUpcallHandler::on_entry/on_exit access thread fields from native

Reviewed-by: mbalao

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:

  • 729b0c7: 8352649: [17u] guarantee(is_result_safe || is_in_asgct()) failed inside AsyncGetCallTrace

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 changed the title Backport 91457e694353386737e325e6fa0253bcefb8d579 8331735: UpcallLinker::on_exit races with GC when copying frame anchor Apr 3, 2025
@openjdk
Copy link

openjdk bot commented Apr 3, 2025

This backport pull request has now been updated with issues from the original commit.

@openjdk openjdk bot added backport rfr Pull request is ready for review labels Apr 3, 2025
@gnu-andrew
Copy link
Member Author

/issue remove 8343144

@openjdk
Copy link

openjdk bot commented Apr 3, 2025

@gnu-andrew
Removing additional issue from issue list: 8343144.

@mlbridge
Copy link

mlbridge bot commented Apr 3, 2025

Webrevs

Copy link
Contributor

@martinuy martinuy 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 contributing this backport. Looks good to me.

@openjdk
Copy link

openjdk bot commented Apr 5, 2025

⚠️ @gnu-andrew This change is now ready for you to apply for maintainer approval. This can be done directly in each associated issue or by using the /approval command.

@gnu-andrew
Copy link
Member Author

Thanks Martin.

/approval request Partial backport of a fix for a race condition in the FFM API. Can lead to crashes when the FFM code manipulates a frame anchor in native mode, which the GC does not expect to happen. Fix is to move the frame anchor copying to Java mode, where the GC will wait for the thread to get to a safepoint. Risk to other code is low as the UpcallLinker is only used by FFM, which is in incubation in 17u.

@openjdk
Copy link

openjdk bot commented Apr 5, 2025

@gnu-andrew
8331735: The approval request has been created successfully.
8286875: The approval request has been created successfully.

@openjdk openjdk bot added the approval label Apr 5, 2025
@gnu-andrew
Copy link
Member Author

/approval request Partial backport of a fix for a race condition in the FFM API. Can lead to crashes when the FFM code manipulates a frame anchor in native mode, which the GC does not expect to happen. Fix is to move the frame anchor copying to Java mode, where the GC will wait for the thread to get to a safepoint. Risk to other code is low as the UpcallLinker is only used by FFM, which is in incubation in 17u. Patch has been reviewed by Martin Balao.

@openjdk
Copy link

openjdk bot commented Apr 5, 2025

@gnu-andrew
8331735: The approval request has been updated successfully.
8286875: The approval request has been updated successfully.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed approval labels Apr 5, 2025
@gnu-andrew
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Apr 8, 2025

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

openjdk bot commented Apr 8, 2025

@gnu-andrew Pushed as commit 8ea7310.

💡 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
backport integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

None yet

2 participants