Skip to content

8367949: JFR: MethodTrace double-counts methods that catch their own exceptions#182

Open
rm-gh-8 wants to merge 2 commits intoopenjdk:masterfrom
rm-gh-8:JDK-8367949-V25
Open

8367949: JFR: MethodTrace double-counts methods that catch their own exceptions#182
rm-gh-8 wants to merge 2 commits intoopenjdk:masterfrom
rm-gh-8:JDK-8367949-V25

Conversation

@rm-gh-8
Copy link
Copy Markdown
Contributor

@rm-gh-8 rm-gh-8 commented Jan 26, 2026

Backporting JDK-8367949: JFR: MethodTrace double-counts methods that catch their own exceptions.

This PR fixes a bug in JEP 520's method tracing instrumentation. The current implementation incorrectly instruments throw bytecodes as method exits, causing:

  1. Overcounting: Exceptions caught within the same method are wrongly counted as extra calls
  2. Undercounting: Method calls aren't counted when exceptions are thrown by callees or when JVM implicit exceptions (like NPE) occur

Ran related tests on linux-x64, linux-aarch64, macos-aarch64 and windows-x64:

make test TEST=jdk_jfr

Results attached:

linux-aarch64-specific-test.log
linux-x64-specific-test.log
macos-aarch64-specific-test.log
windows-x64-specific-test.log


Progress

  • JDK-8367949 needs maintainer approval
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8367949: JFR: MethodTrace double-counts methods that catch their own exceptions (Bug - P3 - Approved)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 182

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Jan 26, 2026

👋 Welcome back rm-gh-8! 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
Copy Markdown

openjdk bot commented Jan 26, 2026

@rm-gh-8 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:

8367949: JFR: MethodTrace double-counts methods that catch their own exceptions

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

➡️ 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 fa2eb626478806dc64fe03d8729f53f7ed26a172 8367949: JFR: MethodTrace double-counts methods that catch their own exceptions Jan 26, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Jan 26, 2026

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

@openjdk openjdk bot added backport Port of a pull request already in a different code base clean Identical backport; no merge resolution required labels Jan 26, 2026
@rm-gh-8 rm-gh-8 marked this pull request as ready for review January 26, 2026 20:38
@openjdk
Copy link
Copy Markdown

openjdk bot commented Jan 26, 2026

⚠️ @rm-gh-8 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.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 26, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Jan 26, 2026

Webrevs

@rm-gh-8
Copy link
Copy Markdown
Contributor Author

rm-gh-8 commented Jan 26, 2026

/approval request for backport of JDK-8367949: JFR: MethodTrace double-counts methods that catch their own exceptions.

This PR fixes a bug in JFR's method tracing instrumentation.

This backport has customer demand.

Low-medium risk - Fixes the incorrect call counting behavior, but the constructor edge cases suggests an incomplete solution.

@openjdk
Copy link
Copy Markdown

openjdk bot commented Jan 26, 2026

@rm-gh-8
8367949: The approval request has been created successfully.

@openjdk openjdk bot added the approval Requires approval; will be removed when approval is received label Jan 26, 2026
@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Feb 24, 2026

@rm-gh-8 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 issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@rm-gh-8
Copy link
Copy Markdown
Contributor Author

rm-gh-8 commented Feb 24, 2026

/keepalive

@openjdk
Copy link
Copy Markdown

openjdk bot commented Feb 24, 2026

@rm-gh-8 The pull request is being re-evaluated and the inactivity timeout has been reset.

@GoeLin
Copy link
Copy Markdown
Member

GoeLin commented Mar 8, 2026

HI @rm-gh-8
I will have a second look at this. Please give an eligible reason for the backport. Similar for others.

@GoeLin
Copy link
Copy Markdown
Member

GoeLin commented Mar 12, 2026

HI @rm-gh-8
could you please merge head and rerun GHA tests?
Thanks.

@rm-gh-8
Copy link
Copy Markdown
Contributor Author

rm-gh-8 commented Mar 12, 2026

@GoeLin Done.

@rm-gh-8
Copy link
Copy Markdown
Contributor Author

rm-gh-8 commented Mar 12, 2026

/approval request for backport of JDK-8367949: JFR: MethodTrace double-counts methods that catch their own exceptions.

Why It's Important:

JFR method tracing produced incorrect invocation counts. Methods that caught their own exceptions were double-counted, while methods where exceptions propagated from callees or were implicit JVM exceptions (NPE, OOME) were never counted at all. This undermines the reliability of jdk.MethodTrace and jdk.MethodTiming events for performance analysis and debugging.

@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 12, 2026

@rm-gh-8
8367949: The approval request has been updated successfully.

@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 Mar 16, 2026
@rm-gh-8
Copy link
Copy Markdown
Contributor Author

rm-gh-8 commented Mar 16, 2026

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Mar 16, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 16, 2026

@rm-gh-8
Your change (at version 514ffc9) is now ready to be sponsored by a Committer.

@shipilev
Copy link
Copy Markdown
Member

Maybe we should wait a bit, until @egahlin gives us the all-clear about this? See Erik's comment in the issue.

@egahlin
Copy link
Copy Markdown
Member

egahlin commented Mar 16, 2026

Maybe we should wait a bit, until @egahlin gives us the all-clear about this? See Erik's comment in the issue.

Mikael found an issue in the method timing event last week (now fixed in JDK 27) while doing some manual experiments. Given that JDK 25 was released less than six months ago and that what we had before this patch works in most cases, I don’t think we need to hurry it into a backport.

My plan is to update the Swing GUI I wrote for JDK 25 and see that everything looks good after the patch.
https://egahlin.github.io/2025/05/31/whats-new-in-jdk-25.html

I will have more time in the next couple weeks.

@egahlin
Copy link
Copy Markdown
Member

egahlin commented Mar 27, 2026

I’ve now had some time to try the new implementation manually, using tracing and timing on java.lang.Object and a few other tricky classes that are hard to have in unit tests. I found a bug, but it also exists in JDK 25.

I also tried the new implementation in the updated GUI, and it works fine.

@shipilev
Copy link
Copy Markdown
Member

shipilev commented Mar 30, 2026

Awesome, thanks!

So to recap, there is nothing blocking from this going into 25u, right, @egahlin?

I found a bug, but it also exists in JDK 25.

Cool. Do you have the bug ID for it?

@egahlin
Copy link
Copy Markdown
Member

egahlin commented Mar 30, 2026

Awesome, thanks!

So to recap, there is nothing blocking from this going into 25u, right, @egahlin?

Correct.

I found a bug, but it also exists in JDK 25.

Cool. Do you have the bug ID for it?

https://bugs.openjdk.org/browse/JDK-8381170

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 clean Identical backport; no merge resolution required ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored

Development

Successfully merging this pull request may close these issues.

4 participants