Skip to content

8373630: r18_tls should not be modified on Windows AArch64#28808

Closed
swesonga wants to merge 2 commits intoopenjdk:masterfrom
swesonga:win-aarch64-c1-r18-tls
Closed

8373630: r18_tls should not be modified on Windows AArch64#28808
swesonga wants to merge 2 commits intoopenjdk:masterfrom
swesonga:win-aarch64-c1-r18-tls

Conversation

@swesonga
Copy link
Member

@swesonga swesonga commented Dec 12, 2025

On Windows, r18_tls is used to store the pointer to the current thread's TEB. Therefore, this register should never be modified (see details in register_aarch64.hpp). One scenario that results in the modification of r18_tls involves virtual threads on Windows. Frames are frozen by Continuation::try_preempt on one carrier thread whose registers are saved. When the frame is thawed, execution can continue on a different carrier thread. When this happens, rthread (x28) is fixed to point to the new carrier thread. The continuation then results in restore_live_registers restoring all the saved registers (including the fixed rthread register). However, this also restores x18, which was the TEB pointer for the previous carrier thread, causing the new carrier thread to execute with the TLS of the previous carrier thread. This causes hangs and occasional crashes in the virtual threads jtreg tests on Windows AArch64 that are resolved by this fix.


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-8373630: r18_tls should not be modified on Windows AArch64 (Bug - P1)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28808

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 12, 2025

👋 Welcome back swesonga! 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 Dec 12, 2025

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

8373630: r18_tls should not be modified on Windows AArch64

Reviewed-by: pchilanomate, aph

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 39 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 (@pchilano, @theRealAph) 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 added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Dec 12, 2025
@openjdk
Copy link

openjdk bot commented Dec 12, 2025

@swesonga 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.

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

mlbridge bot commented Dec 12, 2025

Webrevs

@dean-long
Copy link
Member

Shouldn't the #ifdef be using R18_RESERVED?

@dean-long
Copy link
Member

Nice find. It would be really useful to have a test case that reproduces the problem, and also some idea of how likely it is. I bumped the bug to P1 for now.

@swesonga
Copy link
Member Author

Shouldn't the #ifdef be using R18_RESERVED?

Yes, I have changed the condition to R18_RESERVED

@swesonga
Copy link
Member Author

Nice find. It would be really useful to have a test case that reproduces the problem, and also some idea of how likely it is. I bumped the bug to P1 for now.

The virtual threads MonitorEnterExit test has a 100% failure repro rate on Windows AArch64 without this change (but it does not fail on macosx-aarch64 without this change, even though x18 is also reserved on macosx-aarch64). I was specifically running the testMutualExclusion parametized test with 0 platform threads and at least 2 virtual threads when investigating this behavior.

@theRealAph
Copy link
Contributor

I think this is OK for a quick fix for the upcoming release, but in future save/restore should be fixed so that they exclude r18_tls.

Copy link
Contributor

@pchilano pchilano left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 15, 2025
@swesonga
Copy link
Member Author

/integrate

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

openjdk bot commented Dec 16, 2025

@swesonga
Your change (at version e5a9ef0) is now ready to be sponsored by a Committer.

@theRealAph
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Dec 16, 2025

Going to push as commit a0dd66f.
Since your change was applied there have been 39 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 Dec 16, 2025
@openjdk openjdk bot closed this Dec 16, 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 Dec 16, 2025
@openjdk
Copy link

openjdk bot commented Dec 16, 2025

@theRealAph @swesonga Pushed as commit a0dd66f.

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

@shipilev
Copy link
Member

What a bug! @swesonga, are you handling backports?

@swesonga
Copy link
Member Author

What a bug! @swesonga, are you handling backports?

Yes, I'm preparing the jdk26u backport this afternoon

@dholmes-ora
Copy link
Member

Yes, I'm preparing the jdk26u backport this afternoon

You want to backport to the jdk26 branch not the 26u repo.

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

Labels

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

Development

Successfully merging this pull request may close these issues.

6 participants