Skip to content

Conversation

@tkrodriguez
Copy link
Contributor

@tkrodriguez tkrodriguez commented Feb 5, 2024

This fixes some lurking issues with JVMCI and nmethod related both BarrierSetNMethod and the garbage collection of nmethods. In particular the stack walking in c2v_iterateFrames visits many frames and needs a KeepStackGCProcessedMark for safety. Additionally, JVMCI interacts with nmethods in complex ways and needs some sort of strong root during these interactions. A new JavaThread field has been added that mirrors the way JVMTI keeps nmethods alive.


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-8317368: [JVMCI] SIGSEGV in JVMCIEnv::initialize_installed_code on libgraal (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17714

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 5, 2024

👋 Welcome back never! 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 Feb 5, 2024
@openjdk
Copy link

openjdk bot commented Feb 5, 2024

@tkrodriguez The following labels will be automatically applied to this pull request:

  • graal
  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added graal graal-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Feb 5, 2024
@mlbridge
Copy link

mlbridge bot commented Feb 5, 2024

Webrevs

@openjdk
Copy link

openjdk bot commented Feb 5, 2024

@tkrodriguez this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout tkr-nmethod-keep-alive
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Feb 5, 2024
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Feb 6, 2024
@dougxc
Copy link
Member

dougxc commented Feb 6, 2024

I don't see an easy way to avoid the extra field in JavaThread given that any Java thread can install JVMCI code, not just CompilerThreads.

// Given an instance of HotSpotInstalledCode return the corresponding CodeBlob*.
CodeBlob* get_code_blob(JVMCIObject code);

// Given an instance of HotSpotInstalledCode return the corresponding nmethod.
Copy link
Member

Choose a reason for hiding this comment

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

Can you please improve the comment while here, adding a , after HotSpotInstalledCode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@openjdk
Copy link

openjdk bot commented Feb 6, 2024

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

8317368: [JVMCI] SIGSEGV in JVMCIEnv::initialize_installed_code on libgraal

Reviewed-by: dnsimon, kvn, eosterlund

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

  • 140f567: 8323220: Reassociate loop invariants involved in Cmps and Add/Subs
  • a293bdf: 8330197: Make javac/diags/example release agnostic
  • da75e01: 8330196: Make java/lang/invoke/defineHiddenClass/BasicTest release agnostic
  • ddc3921: 8330103: Compiler memory statistics should keep separate records for C1 and C2
  • 273df62: 8328792: Parallel: Refactor PSParallelCompact::summary_phase
  • a3fecdb: 8329764: G1: Handle null references during verification first
  • 60d88b7: 8330176: Typo in Linker javadoc
  • 3f1d9c4: 8329257: AIX: Switch HOTSPOT_TOOLCHAIN_TYPE from xlc to gcc
  • 5404b4e: 8330105: SharedRuntime::resolve* should respect interpreter-only mode
  • d22d560: 8329864: TestLibGraal.java still crashes with assert(_stack_base != nullptr)
  • ... and 3 more: https://git.openjdk.org/jdk/compare/c1c99a669bb7f9928086db6a4ecfc90c410ffbb0...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 Feb 6, 2024
@bridgekeeper
Copy link

bridgekeeper bot commented Mar 12, 2024

@tkrodriguez 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!

@dougxc
Copy link
Member

dougxc commented Apr 13, 2024

Can this be merged soon Tom?

@tkrodriguez
Copy link
Contributor Author

I resync'ed with master and mach5 testing was clean. I'll ping some likely reviewers.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Seems fine.

May be we should consider specialized jvmciJavaThread subclass to keep all JVMCI fields instead of having them in JavaThread even when Graal is not used.

@vnkozlov
Copy link
Contributor

@tkrodriguez did you consider an nmethod's state similar to not_installed to avoid this issue?

Copy link
Contributor

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

@tkrodriguez
Copy link
Contributor Author

You mean to add a level of indirection for the JVMCI specific fields? Some of them would be fine with that but a few really want direct access. We'd have to rework some interpreter assembly and code generation on the Graal side for those fields that accessed directly. I could look into it at some point.

@tkrodriguez
Copy link
Contributor Author

Regarding the comment about the special state, the problem is that the nmethod must be visited by the GC while it's alive and the only way to ensure that for it to be explicitly visited during GC. There's no way to fixup the nmethod after the fact.

@tkrodriguez
Copy link
Contributor Author

Thanks for the reviews.

/integrate

@openjdk
Copy link

openjdk bot commented Apr 17, 2024

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

  • fb4cf1c: 8329636: Deprecate -XX:+PreserveAllAnnotations
  • d1c6cd1: 8330133: libj2pkcs11.so crashes on some pkcs#11 v3.0 libraries
  • 76cbe48: 8329430: MetaspaceShared::preload_and_dump should clear pending exception
  • f7c8413: 8326116: JFR: Add help option to -XX:StartFlightRecording
  • 941bee1: 8327640: Allow NumberFormat strict parsing
  • 2ede143: 8330279: Typo in java.text.Bidi class description
  • 90df3b7: 8329190: (ch) DatagramChannel.receive should throw ClosedChannelException when called on closed channel
  • f11a496: 8180450: secondary_super_cache does not scale well
  • bfff02e: 8330165: C2: make superword consistently use PhaseIdealLoop::register_new_node()
  • e073d5b: 8329665: fatal error: memory leak: allocating without ResourceMark
  • ... and 23 more: https://git.openjdk.org/jdk/compare/c1c99a669bb7f9928086db6a4ecfc90c410ffbb0...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Apr 17, 2024

@tkrodriguez Pushed as commit f6f038a.

💡 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

graal graal-dev@openjdk.org hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants