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

8264358: Don't create invalid oop in method handle tracing #3242

Closed

Conversation

@stefank
Copy link
Member

@stefank stefank commented Mar 29, 2021

The mh field in:

struct MethodHandleStubArguments {
  const char* adaptername;
  oopDesc* mh;
  intptr_t* saved_regs;
  intptr_t* entry_sp;
};

doesn't always point to a valid object. The oopDesc* is then implicitly converted to an oop here:

void trace_method_handle_stub_wrapper(MethodHandleStubArguments* args) {
  trace_method_handle_stub(args->adaptername,
                           args->mh,
                           args->saved_regs,
                           args->entry_sp);
}

This gets caught by my ad-hoc verification code that verifies oops when they are created/used.

I propose that we don't create an oop until it mh is actually used, and it has been checked that the argument should contain a valid oop. I started with a more elaborate fix that changed the type of mh to be void*, but then reverted to a more targetted fix to remove the early oopDesc* > oop conversion.

One thing that I am curious about is this code inside trace_method_handle_stub:

if (has_mh && oopDesc::is_oop(mh)) {
  mh->print_on(&ls);

Delaying the oopDesc* > oop conversion to after the has_mh check solves my verification failure, but I wonder if the oopDesc::is_oop(mh) call is really needed when we have the has_mh check?


Progress

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

Issue

  • JDK-8264358: Don't create invalid oop in method handle tracing

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3242/head:pull/3242
$ git checkout pull/3242

Update a local copy of the PR:
$ git checkout pull/3242
$ git pull https://git.openjdk.java.net/jdk pull/3242/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3242

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3242.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Mar 29, 2021

👋 Welcome back stefank! 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.

Loading

@openjdk openjdk bot added the rfr label Mar 29, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 29, 2021

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

  • hotspot-compiler

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.

Loading

@mlbridge
Copy link

@mlbridge mlbridge bot commented Mar 29, 2021

Webrevs

Loading

@stefank
Copy link
Member Author

@stefank stefank commented Apr 9, 2021

Could I get a review for this? It is a super small change.

Loading

Copy link
Contributor

@neliasso neliasso left a comment

Looks good.

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Apr 9, 2021

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

8264358: Don't create invalid oop in method handle tracing

Reviewed-by: neliasso

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

  • b3782ea: 8264918: [JVMCI] getVtableIndexForInterfaceMethod doesn't check that type and method are related
  • f7a6c63: 8259822: [PPC64] Support the prefixed instruction format added in POWER10
  • a45733f: 8264779: Fix doclint warnings in java/nio
  • 3e57924: 8264885: Fix the code style of macro in aarch64_neon_ad.m4
  • 051c117: 8264923: PNGImageWriter.write_zTXt throws Exception with a typo
  • 1c6b113: 8264513: Cleanup CardTableBarrierSetC2::post_barrier
  • 666fd62: 8264881: Remove the old development option MemProfiling
  • 951f277: 8264874: Build interim-langtools for HotSpot only if Graal is enabled
  • 719f95e: 8260693: Provide the support for specifying a signer in keytool -genkeypair
  • 77b1673: 8256245: AArch64: Implement Base64 decoding intrinsic
  • ... and 147 more: https://git.openjdk.java.net/jdk/compare/aefc1560b51f0ce96d8f5ce396ba0d2fe08fd650...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.

Loading

@openjdk openjdk bot added the ready label Apr 9, 2021
@stefank
Copy link
Member Author

@stefank stefank commented Apr 12, 2021

Thanks, @neliasso.
/integrate

Loading

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Looks good to me too.

Loading

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

@openjdk openjdk bot commented Apr 12, 2021

@stefank Since your change was applied there have been 173 commits pushed to the master branch:

  • 627ad9f: 8262328: Templatize JVMFlag boilerplate access methods
  • c15680e: 8264868: Reduce inclusion of registerMap.hpp and register.hpp
  • 5784f6b: 8264948: Check for TLS extensions total length
  • 42f4d70: 8264649: runtime/InternalApi/ThreadCpuTimesDeadlock.java crash in fastdebug C2 with -XX:-UseTLAB
  • 76bd313: 8264872: Dependencies: Migrate to PerfData counters
  • 07c8ff4: 8264871: Dependencies: Miscellaneous cleanups in dependencies.cpp
  • 863feab: 8005295: Use mandated information for printing of repeating annotations
  • f26cd2a: 8264997: Remove SystemDictionary::cache_get
  • 9ebc497: 8264765: BreakIterator sees bogus sentence boundary in parenthesized “i.e.” phrase
  • ec31b3a: 8264727: Shenandoah: Remove extraneous whitespace from phase timings report
  • ... and 163 more: https://git.openjdk.java.net/jdk/compare/aefc1560b51f0ce96d8f5ce396ba0d2fe08fd650...master

Your commit was automatically rebased without conflicts.

Pushed as commit b1ebf82.

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

Loading

@stefank
Copy link
Member Author

@stefank stefank commented Apr 12, 2021

Thanks, @TobiHartmann

Loading

@stefank stefank deleted the 8264358_trace_method_handle_oops branch May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants