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

8274298: JFR Thread Sampler thread must not acquire malloc lock after suspending a thread because of possible deadlock #5977

wants to merge 7 commits into from


Copy link

@mgronlun mgronlun commented Oct 17, 2021


JDK-8233705 introduced a means to only iterate the incrementally tagged Klasses, instead of the entire set of Klasses in the JVM, as part of serializing metadata information. The newly tagged Klasses are enqueued onto a thread-local buffer using a load barrier. If the buffer runs out of space, a new buffer is accommodated, either from a free list or via a new allocation.

This is problematic for the JfrThreadSampler because the thread it has suspended could hold the malloc lock. For example, this could be the case if the suspended thread was in the process of deoptimization. The Deoptimization::UnrollBlock is a CHeapObj, and the vframes arrays use the NEW_C_HEAP_ARRAY macro.

The solution to this problem is to explicitly monitor the size of the thread-local buffer of the JfrThreadSampler thread, and pre-emptively renew it before thread suspension.

Testing: jdk_jfr, stress testing



  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed


  • JDK-8274298: JFR Thread Sampler thread must not acquire malloc lock after suspending a thread because of possible deadlock



Using git

Checkout this PR locally:
$ git fetch pull/5977/head:pull/5977
$ git checkout pull/5977

Update a local copy of the PR:
$ git checkout pull/5977
$ git pull pull/5977/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5977

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

Using diff file

Download this PR as a diff file:

Copy link

@bridgekeeper bridgekeeper bot commented Oct 17, 2021

👋 Welcome back mgronlun! 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 openjdk bot added the rfr label Oct 17, 2021
Copy link

@openjdk openjdk bot commented Oct 17, 2021

@mgronlun The following label will be automatically applied to this pull request:

  • hotspot-jfr

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 hotspot-jfr label Oct 17, 2021
Copy link

@mlbridge mlbridge bot commented Oct 17, 2021


Copy link

@bridgekeeper bridgekeeper bot commented Nov 14, 2021

@mgronlun This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

egahlin approved these changes Dec 6, 2021
Copy link

@openjdk openjdk bot commented Dec 6, 2021

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

ℹ️ This project also has non-automated pre-integration requirements. Please see the file for details.

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

8274298: JFR Thread Sampler thread must not acquire malloc lock after suspending a thread because of possible deadlock

Reviewed-by: egahlin

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 64 new commits pushed to the master branch:

  • 42d9b1b: 8277106: Cannot compile certain sources with --release
  • ba86dd4: 8278445: ProblemList tools/jpackage/share/ on macosx-x64
  • 92aa75b: 8274903: Zero: Support AsyncGetCallTrace
  • 8345453: 8272392: Lanai: SwingSet2. Black background on expanding tree node
  • 9b74749: 8276660: Scalability bottleneck in
  • 2478158: 8277361: java/nio/channels/Channels/ fails with OOM error
  • 8af3b27: 8277850: C2: optimize mask checks in counted loops
  • 3e93e0b: 8276769: -Xshare:auto should tolerate problems in the CDS archive
  • 79165b7: 8278324: Update the --generate-cds-archive jlink plugin usage message
  • 40d726b: 8278310: Improve logging in CDS
  • ... and 54 more:

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 added the ready label Dec 6, 2021
Copy link

@openjdk openjdk bot commented Dec 6, 2021

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

Copy link

@mgronlun mgronlun commented Dec 9, 2021


Copy link

@openjdk openjdk bot commented Dec 9, 2021

Going to push as commit 965ea8d.
Since your change was applied there have been 81 commits pushed to the master branch:

  • 84baea7: 8278433: Use snippets in jdk.incubator.foreign documentation
  • 1ea766d: 8278419: JFR jcmd option contract "This value cannot be changed once JFR has been initialized" is not enforced
  • 62a7f5d: 8254318: Remove .hgtags
  • d170682: 8278466: "spurious markup" warnings in snippets when building docs-reference
  • 8ef1a23: 8278311: Debian packaging doesn't work
  • 3524355: 8277882: New subnode ideal optimization: converting "c0 - (x + c1)" into "(c0 - c1) - x"
  • 83e6a4c: 8255409: Support the new C_GetInterfaceList, C_GetInterface, and C_SessionCancel APIs in PKCS#11 v3.0
  • 3cec700: 8278463: [test] Serialization WritePrimitive test revised for readFully test fails
  • 03bf55f: 8277980: ObjectMethods::bootstrap throws NPE when lookup is null
  • 3893f4f: 8278330: dump stack trace if the jvmti test nsk/jvmti/GetThreadState/thrstat002 is failed with wrong thread state
  • ... and 71 more:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Dec 9, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Dec 9, 2021
Copy link

@openjdk openjdk bot commented Dec 9, 2021

@mgronlun Pushed as commit 965ea8d.

💡 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
hotspot-jfr integrated
2 participants