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 - Requested)

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

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval Requires approval; will be removed when approval is received backport Port of a pull request already in a different code base rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants