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

JDK-8307331: Correctly update line maps when class redefine rewrites bytecodes #13795

Closed
wants to merge 1 commit into from

Conversation

adinn
Copy link
Contributor

@adinn adinn commented May 4, 2023

This small change ensures that repeated bytecode rewrites necessitated by class pool index updates are applied cumulatively when updating the method line number table. The current code applies each change to the original table which means only the last one is applied (and even then with the wrong adjustment).


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-8307331: Correctly update line maps when class redefine rewrites bytecodes

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13795

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 4, 2023

👋 Welcome back adinn! 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 Pull request is ready for review label May 4, 2023
@openjdk
Copy link

openjdk bot commented May 4, 2023

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

  • hotspot-runtime

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-runtime hotspot-runtime-dev@openjdk.org label May 4, 2023
@adinn
Copy link
Contributor Author

adinn commented May 4, 2023

This fix has been tested manually using the test case linked from the JIRA. An automated test might be possible but is difficult to perform as it would involve hot swapping code and checking line number adjustments via JDWP. Advice from the serviceability team on how to implement such a test would be welcome.

@mlbridge
Copy link

mlbridge bot commented May 4, 2023

Webrevs

@adinn
Copy link
Contributor Author

adinn commented May 4, 2023

/label serviceability

@openjdk openjdk bot added the serviceability serviceability-dev@openjdk.org label May 4, 2023
@openjdk
Copy link

openjdk bot commented May 4, 2023

@adinn
The serviceability label was successfully added.

@adinn
Copy link
Contributor Author

adinn commented May 4, 2023

@coleenp @plummercj Any chance of feedback or a review for this patch?

@DanHeidinga
Copy link
Contributor

@adinn Looking at the closely related code, is the same problem present for adjust_exception_table & adjust_local_var_table? Both appear to always reach for the original value from the method, though unlike the line number table, there's no member variable cached in the Relocator for either of them.

@plummercj
Copy link
Contributor

@adinn This is not code I'm at all familiar with. Perhaps @sspitsyn can help.

Copy link
Contributor

@sspitsyn sspitsyn 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.
Thank you for taking care about it!
Thanks,
Serguei

@openjdk
Copy link

openjdk bot commented May 5, 2023

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

8307331: Correctly update line maps when class redefine rewrites bytecodes

Reviewed-by: sspitsyn

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

  • a44e890: 8307308: Add serviceability_ttf_virtual group to exclude jvmti tests developed for virtual threads
  • 46df171: 8304948: [vectorapi] C2 crashes when expanding VectorBox
  • 111858f: 8307489: ProblemList jdk/incubator/vector/LoadJsvmlTest.java on windows-x64
  • 197d0cc: 8294983: SSLEngine throws ClassCastException during handshake
  • a87262e: 8307295: Add warning to not create new ACC flags
  • 0c6529d: 8307156: native_thread not protected by TLH
  • 5ca0b08: 8307133: Open source some JTable jtreg tests
  • 2adb3b4: 8306943: Open source several dnd AWT tests
  • dc4096c: 8304937: BufferedFieldBuilder.Model missing writeTo(DirectClassBuilder)
  • 29233e0: 8307448: Test RedefineSharedClassJFR fail due to wrong assumption
  • ... and 23 more: https://git.openjdk.org/jdk/compare/c8f37564bf0983f449195434378479e1adfc1466...master

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 Pull request is ready to be integrated label May 5, 2023
@adinn
Copy link
Contributor Author

adinn commented May 5, 2023

@adinn Looking at the closely related code, is the same problem present for adjust_exception_table & adjust_local_var_table? Both appear to always reach for the original value from the method, though unlike the line number table, there's no member variable cached in the Relocator for either of them.

@DanHeidinga I also thought that at first -- but it turns out the answer is no. Those other cases are different because the relocator directly updates the relevant offsets in the data located at the end of the ConstMethod. The line number table needs to be uncompressed and recompressed at each update, possibly ending up with a different size compressed array. So, the changes need to accumulate in a succession of compressed arrays held in the relocator the last of which gets recombined with the new version of the method when the method clone eventually happens.

@adinn
Copy link
Contributor Author

adinn commented May 5, 2023

@sspitsyn Thanks for the review.

@adinn
Copy link
Contributor Author

adinn commented May 5, 2023

/integrate

@openjdk
Copy link

openjdk bot commented May 5, 2023

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

  • 302bc2f: 8307421: Fix comment in g1CollectionSetChooser.hpp after JDK-8306836
  • e19cf26: 8307196: Dangling pointer warning for MetadataAllocationRequest
  • 1b143ba: 8307378: Allow collectors to provide specific values for GC notifications' actions
  • a44e890: 8307308: Add serviceability_ttf_virtual group to exclude jvmti tests developed for virtual threads
  • 46df171: 8304948: [vectorapi] C2 crashes when expanding VectorBox
  • 111858f: 8307489: ProblemList jdk/incubator/vector/LoadJsvmlTest.java on windows-x64
  • 197d0cc: 8294983: SSLEngine throws ClassCastException during handshake
  • a87262e: 8307295: Add warning to not create new ACC flags
  • 0c6529d: 8307156: native_thread not protected by TLH
  • 5ca0b08: 8307133: Open source some JTable jtreg tests
  • ... and 26 more: https://git.openjdk.org/jdk/compare/c8f37564bf0983f449195434378479e1adfc1466...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 5, 2023
@openjdk openjdk bot closed this May 5, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 5, 2023
@openjdk
Copy link

openjdk bot commented May 5, 2023

@adinn Pushed as commit f94f957.

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

@dholmes-ora
Copy link
Member

@adinn Please wait for two reviews for hotspot changes unless designated as trivial. Thanks.

@adinn
Copy link
Contributor Author

adinn commented May 9, 2023

@dholmes-ora Apologies for jumping the gun. Do I need to obtain a second, retrospective review?

@sspitsyn
Copy link
Contributor

sspitsyn commented May 9, 2023

Do I need to obtain a second, retrospective review?

Yes, Serviceability changes need two reviews unless they are not trivial.

@adinn
Copy link
Contributor Author

adinn commented May 9, 2023

@sspitsyn @dholmes-ora Could you suggest a suitable reviewer?

@dholmes-ora
Copy link
Member

I can't specifically suggest anyone but will try to find someone. I looked but don't know the code.

@adinn
Copy link
Contributor Author

adinn commented May 9, 2023

@dholmes-ora Thanks. Perhaps @coleenp might be able to review it?

Copy link
Member

@tstuefe tstuefe 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 to me. Thank you for the well written description text in the JBS issue.

I hesitated a bit at the use of TraceRelocator instead of our usual LogStream/LogTarget combination with UL, but I see that this is pre-existing usage, so its fine.

Another preexisting issue I noted is that CompressedWriteStream manages its internal buffer via RA, and grows inside RA too. That is suboptimal since we usually cannot reclaim the old buffer on resize since its rarely the top arena allocation. Oh, we also just allocate, we never even try resizing... (CompressedWriteStream::grow()).

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

Sorry I didn't see this in my mail until just now. Wow, good analysis and makes sense. Late second review.

@adinn
Copy link
Contributor Author

adinn commented May 9, 2023

@tstuefe @coleenp Thank you for the reviews!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org
7 participants