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

8283224: Remove THREAD_NOT_ALIVE from possible JDWP error codes #10189

Closed
wants to merge 1 commit into from

Conversation

plummercj
Copy link
Contributor

@plummercj plummercj commented Sep 7, 2022

THREAD_NOT_ALIVE originates from JVMTI. However, the debug agent converts it to INVALID_THREAD before passing it on to the debug agent client (the debugger, usually JDI), so debug agent users (JDI) should never see it. Currently ThreadReference.forceEarlyReturn() is the only API that even bothers to check for it, and it throws com.sun.jdi.IllegalThreadStateException, which is the same thing it already does for INVALID_THREAD.

In the JDWP spec I change the description of THREAD_NOT_ALIVE to "Not used". If you have a suggestion for better wording, please let me now. (I was thinking maybe "Unused" would be better.

In the JDI ThreadReference.forceEarlyReturn implementation, I removed the code that checks for THREAD_NOT_ALIVE since it should never occur. There is no behavior change associated with this change, and there is no JDI spec update necessary. The spec already says IllegalThreadStateException means "the thread is not suspended", and not being alive implies not suspended.

Note the JDWP spec for ThreadReference.ForceEarlyReturn used to mention THREAD_NOT_ALIVE as a possible error code, but it was removed as part of the loom work.


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-8283224: Remove THREAD_NOT_ALIVE from possible JDWP error codes

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10189

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 7, 2022

👋 Welcome back cjplummer! 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 changed the title 8283224 8283224: Remove THREAD_NOT_ALIVE from possible JDWP error codes Sep 7, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 7, 2022
@openjdk
Copy link

openjdk bot commented Sep 7, 2022

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

  • core-libs
  • serviceability

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 serviceability serviceability-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Sep 7, 2022
@mlbridge
Copy link

mlbridge bot commented Sep 7, 2022

Webrevs

@plummercj
Copy link
Contributor Author

/label remove core-libs

@openjdk openjdk bot removed the core-libs core-libs-dev@openjdk.org label Sep 7, 2022
@openjdk
Copy link

openjdk bot commented Sep 7, 2022

@plummercj
The core-libs label was successfully removed.

@@ -595,9 +595,6 @@ public void forceEarlyReturn(Value returnValue) throws InvalidTypeException,
case JDWP.Error.THREAD_NOT_SUSPENDED:
throw new IncompatibleThreadStateException(
"Thread not suspended");
case JDWP.Error.THREAD_NOT_ALIVE:
throw new IncompatibleThreadStateException(
"Thread has not started or has finished");
Copy link
Contributor

Choose a reason for hiding this comment

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

When doing anything here we have to take into account that the debugger (or JDI tool) may be connected to a target VM on an older or newer release. So if I read the issue correctly, the reply to the ThreadReference/ForceEarlyReturn command never returned THREAD_NOT_ALIVE so it's okay to remove the mapping to IncompatibleThreadStateException.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So if I read the issue correctly, the reply to the ThreadReference/ForceEarlyReturn command never returned THREAD_NOT_ALIVE so it's okay to remove the mapping to IncompatibleThreadStateException.

It was not some recent change in the debug agent that eliminated returning THREAD_NOT_ALIVE. However, I can't say for sure that it has never returned it. In fact I would assume at some point it did return it, but that could be as far back as the JVMDI days.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, if any command gets a THREAD_NOT_ALIVE, the following is done:

return new InternalException("Unexpected JDWP Error: " + errorCode, errorCode);

@openjdk
Copy link

openjdk bot commented Sep 7, 2022

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

8283224: Remove THREAD_NOT_ALIVE from possible JDWP error codes

Reviewed-by: alanb, 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 7 new commits pushed to the master branch:

  • 2259e42: 8293197: Avoid double racy reads from non-volatile fields in SharedSecrets
  • 205f992: 8293326: jdk/sun/security/tools/jarsigner/compatibility/SignTwice.java slow on Windows
  • 710a143: 8293445: clhsdb "thread" command gives incorrect error message for bad threadID
  • 57930f8: 8293285: x86_64: Move libm stub implementations to StubGenerator
  • 5b4c415: 8293254: x86_64: Extract arraycopy stub implementations into a separate file
  • fb6eb6f: 8293245: x86_64: Extract Adler32 stub implementation into stubGenerator_x86_64_adler.cpp
  • da59618: 8264744: (fs) Use file cloning in Linux version of Files::copy method

Please see this link for an up-to-date comparison between the source branch of this pull request and 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.

➡️ 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 Sep 7, 2022
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.

This looks good to me.
Thanks,
Serguei

@plummercj
Copy link
Contributor Author

Thanks Serguei and Alan!

/integrate

@openjdk
Copy link

openjdk bot commented Sep 7, 2022

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

  • 76df73b: 8293456: runtime/os/TestTracePageSizes.java sub-tests fail with "AssertionError: No memory range found for address: NNNN"
  • 32c7b62: 8293146: Strict DateTimeFormatter fails to report an invalid week 53
  • 02dce24: 8207166: jdk/jshell/JdiHangingLaunchExecutionControlTest.java - launch timeout
  • d36abbe: 8293496: ProblemList runtime/os/TestTracePageSizes.java on linux-x64
  • 1ee59ad: 8289798: Update to use jtreg 7
  • 5934669: 8292383: Create a SymbolHandle type to use for ResourceHashtable
  • 6ff4775: 8285487: AArch64: Do not generate unneeded trampolines for runtime calls
  • d696104: 4850101: Setting mnemonic to VK_F4 underlines the letter S in a button.
  • 14fd1b6: 8292921: Rewrite object field printer
  • 4f9065d: 8293333: Broken links in JDI specification
  • ... and 7 more: https://git.openjdk.org/jdk/compare/85d4b49151e9529051f1ed344749a487d3e92165...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Sep 7, 2022

@plummercj Pushed as commit aff9a69.

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

@plummercj plummercj deleted the 8283224_jdwp_not_alive branch October 11, 2022 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org
3 participants