Skip to content

Conversation

krk
Copy link

@krk krk commented Aug 14, 2025

Backport of JDK-8212155.

The patch did not apply cleanly due to a merge conflict. The original code JvmtiThreadState::state_for(JavaThread::current()) had already been refactored to JavaThread::current()->jvmti_thread_state() in this branch.

I have also removed the @requires vm.jvmti tag from the test, as it is not supported by the jtreg version in JDK 11.

For JDK 8, DynamicCodeGeneratedTest.sh was added as the runner, which compiles the library first.

The DynamicCodeGeneratedTest was confirmed to sometimes crash without this patch and passes with it.


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-8212155 needs maintainer approval

Issue

  • JDK-8212155: Race condition when posting dynamic_code_generated event leads to JVM crash (Bug - P3 - Approved)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 674

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 14, 2025

👋 Welcome back krk! 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 Aug 14, 2025

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

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

8212155: Race condition when posting dynamic_code_generated event leads to JVM crash

Reviewed-by: phh, 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 1 new commit pushed to the master branch:

  • c0a36d8: 8366574: Bump update version of OpenJDK: 8u482

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.

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 (@phohensee, @shipilev) 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 Backport 64ec8b3e5c8a8d44c92591710d73b833f13c1500 8212155: Race condition when posting dynamic_code_generated event leads to JVM crash Aug 14, 2025
@openjdk
Copy link

openjdk bot commented Aug 14, 2025

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

@openjdk openjdk bot added the backport Port of a pull request already in a different code base label Aug 14, 2025
@openjdk
Copy link

openjdk bot commented Aug 14, 2025

@krk Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

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

mlbridge bot commented Aug 14, 2025

Webrevs

@krk
Copy link
Author

krk commented Aug 14, 2025

Failing tests seem unrelated:

Windows x64 release and debug build:

No configurations found for /cygdrive/c/a/jdk8u-dev/jdk8u-dev/jdk/! Please run configure to create a configuration.
Makefile:55: *** Cannot continue.  Stop.

macOS x64 jdk/security_infra:

security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java#microsoftecc2017 

Looks similar to #673

Linux x86 hotspot/tier1:

gc/concurrentMarkSweep/CheckAllocateAndSystemGC.java 

Test timed out:

ACTION: main -- Error. Program `/home/runner/jdk-linux-x86/jdk-1.8.0-internal+0_linux-x86_bin/j2sdk-image/bin/java' timed out (timeout set to 480000ms, elapsed time including timeout handling was 480396ms).
REASON: User specified action: run main/othervm CheckAllocateAndSystemGC 

also observed in #628 (comment)

@openjdk
Copy link

openjdk bot commented Aug 14, 2025

⚠️ @krk 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.

@krk
Copy link
Author

krk commented Aug 15, 2025

/approval request Fixes a critical JVM crash from a race condition when posting dynamic_code_generated JVMTI events.

The patch required manual conflict resolution in JvmtiExport.cpp because JvmtiThreadState::state_for() was previously refactored in this branch.

For JDK 8, DynamicCodeGeneratedTest.sh was added as the runner, which compiles the library first.

This fix has been stable in mainline since June 2021. The risk is low, as the fix is a minimal, defensive check.

@openjdk
Copy link

openjdk bot commented Aug 15, 2025

@krk
8212155: The approval request has been created successfully.

@openjdk openjdk bot added the approval Requires approval; will be removed when approval is received label Aug 15, 2025
@krk
Copy link
Author

krk commented Aug 19, 2025

/approval request Fixes a critical JVM crash from a race condition when posting dynamic_code_generated JVMTI events. We have seen the JVM crashes with production services running with async-profiler on this code path.

The patch required manual conflict resolution, see 8u PR. This fix has been stable in mainline since June 2021; there is a minor testbug bugtail. The risk is low and benefit is high: adds a simple defensive check, avoids crashes seen in the wild, matches the backports in all other currently active JDK releases.

@openjdk
Copy link

openjdk bot commented Aug 19, 2025

@krk
8212155: The approval request has been updated successfully.

@krk
Copy link
Author

krk commented Aug 22, 2025

@gnu-andrew, @jerboaa -- would you be the right reviewers for this? It is a fairly safe change that avoids production JVM crashes with profilers.

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.

This looks fine. Like the backports to other releases, this looks like a nice safety net.

But yes, @gnu-andrew or @jerboaa would need to approve it for JDK 8.

@jerboaa
Copy link
Contributor

jerboaa commented Sep 2, 2025

jdk8u-dev is currently closed for pushes. I'll approve once JDK-8366574 is in.

In the meantime please merge latest master to avoid the windows build failure in CI.

@krk
Copy link
Author

krk commented Sep 3, 2025

After merge from master, the windows build error is gone, thanks for the suggestion.

New failures seem unrelated to the current PR:

CAInterop

There are CAInterop.java failures in different architectures, similar to #673. The CA roots in question are actalisauthenticationrootca and in some cases entrustrootcag4.

macOS x64 jdk/tier1

multiple failures with "Target VM failed to initialize", similar to the closed https://bugs.openjdk.org/browse/JDK-8286193

GC segfault

Segfault in CompactibleFreeListSpace::block_size on Linux x86 hotspot/tier1 gc/6581734/Test6581734.java is tracked in JDK-8332853.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed approval Requires approval; will be removed when approval is received labels Sep 3, 2025
@krk
Copy link
Author

krk commented Sep 3, 2025

/integrate

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

openjdk bot commented Sep 3, 2025

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

@shipilev
Copy link
Member

shipilev commented Sep 3, 2025

/sponsor

@openjdk
Copy link

openjdk bot commented Sep 3, 2025

Going to push as commit 942d6d0.
Since your change was applied there has been 1 commit pushed to the master branch:

  • c0a36d8: 8366574: Bump update version of OpenJDK: 8u482

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 3, 2025
@openjdk openjdk bot closed this Sep 3, 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 Sep 3, 2025
@openjdk
Copy link

openjdk bot commented Sep 3, 2025

@shipilev @krk Pushed as commit 942d6d0.

💡 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 Port of a pull request already in a different code base integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants