Skip to content

8249627: Degrade Thread.suspend and Thread.resume #10324

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

Closed
wants to merge 11 commits into from

Conversation

AlanBateman
Copy link
Contributor

@AlanBateman AlanBateman commented Sep 18, 2022

Degrade Thread.suspend/resume to throw UOE unconditionally.

Another step in the removal of this deadlock prone mis-feature from the user-facing API. Thread.suspend/resume have been deprecated since JDK 1.2 (1998) and terminally deprecated since Java 14. ThreadGroup.suspend/resume were degraded to throw UOE in Java 19. As of Java 19, Thread.suspend/resume continues to work for platform threads but throws UOE for virtual threads. The next step is to degrade both methods to throw UOE for all threads. A corpus search of 19M classes in 113k JAR files found only 22 classes using these methods so this change is unlikely to be disruptive.

The change requires some minor adjustments to the JVM TI and JDWP specifications, and a minor update to the JDI docs.

Leonid Mesnik is working on PR10351 to remove/replace the last few usages of Thread.suspend/resume from the hotspot tests (most of these can use JVMTI SuspendThread/ResumeThread).


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
  • Change requires a CSR request to be approved

Issues

  • JDK-8249627: Degrade Thread.suspend and Thread.resume
  • JDK-8293975: Degrade Thread.suspend and Thread.resume (CSR)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10324

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 18, 2022

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

openjdk bot commented Sep 18, 2022

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

  • build
  • core-libs
  • hotspot
  • javadoc
  • security
  • 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 javadoc javadoc-dev@openjdk.org serviceability serviceability-dev@openjdk.org security security-dev@openjdk.org hotspot hotspot-dev@openjdk.org build build-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Sep 18, 2022
@openjdk
Copy link

openjdk bot commented Sep 18, 2022

@AlanBateman Unknown command remove - for a list of valid commands use /help.

@openjdk
Copy link

openjdk bot commented Sep 18, 2022

@AlanBateman Unknown command remove - for a list of valid commands use /help.

@openjdk
Copy link

openjdk bot commented Sep 18, 2022

@AlanBateman Unknown command remove - for a list of valid commands use /help.

@AlanBateman
Copy link
Contributor Author

/label remove build
/label remove javadoc
/label remove security

@openjdk openjdk bot removed the build build-dev@openjdk.org label Sep 18, 2022
@openjdk
Copy link

openjdk bot commented Sep 18, 2022

@AlanBateman
The build label was successfully removed.

@openjdk openjdk bot removed the javadoc javadoc-dev@openjdk.org label Sep 18, 2022
@openjdk
Copy link

openjdk bot commented Sep 18, 2022

@AlanBateman
The javadoc label was successfully removed.

@openjdk openjdk bot removed the security security-dev@openjdk.org label Sep 18, 2022
@openjdk
Copy link

openjdk bot commented Sep 18, 2022

@AlanBateman
The security label was successfully removed.

@AlanBateman
Copy link
Contributor Author

/csr

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Sep 18, 2022
@openjdk
Copy link

openjdk bot commented Sep 18, 2022

@AlanBateman this pull request will not be integrated until the CSR request JDK-8293975 for issue JDK-8249627 has been approved.

@stuart-marks
Copy link
Member

Code changes look fine, though I didn't look too closely at the JDWP and JVMTI stuff. Nice use of JUnit.

Not a big deal, but I could see leaving the links from Thread::suspend et. al. to the "Why deprecated?" doc, and then updating that doc to make it clear that the mechanisms have in fact been removed, but leaving the rationale that's there mostly in place.

Might also be useful in the CSR to re-emphasize that this does not affect the ability to suspend and resume threads through the debugging interfaces. Of course the specs in those areas need to be updated so they no longer deal with the case of a thread that's been suspended through the API, but the debugging mechanisms' functions themselves are unchanged.

@AlanBateman AlanBateman marked this pull request as ready for review September 21, 2022 13:24
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 21, 2022
@mlbridge
Copy link

mlbridge bot commented Sep 21, 2022

Webrevs

Copy link
Contributor

@plummercj plummercj left a comment

Choose a reason for hiding this comment

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

Changes look good.

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.
Thanks,
Serguei

@jaikiran
Copy link
Member

jaikiran commented Sep 22, 2022

Hello Alan, this PR deletes the CountStackFrames.java test case. Is that intentional? Looking at that test case it doesn't have any suspend/resume related testing and instead is just verifying that Thread.countStackFrames() throws the expected UnsupportedOperationException.

Edit: Please ignore what I said - I now see that these tests have been moved to a new test file.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

One minor nit but otherwise looks good!

Thanks.

@@ -494,7 +494,6 @@ private static ThreadGroup getRootGroup() {
* calling thread is not allowed to modify the thread argument.
* <p>
* This method is invoked for the current security manager by the
* {@code stop}, {@code suspend}, {@code resume},
Copy link
Member

Choose a reason for hiding this comment

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

Why is stop being removed in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is stop being removed in this PR?

It's just the sequencing of the two PRs and avoid merge conflicts. The Thread.stop should really edit this sentence, then this PR will edit it again. It was simpler to just do the SM edits in one PR.

Copy link
Member

@jaikiran jaikiran left a comment

Choose a reason for hiding this comment

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

The java.base changes look fine to me.

@AlanBateman
Copy link
Contributor Author

Leonid has integrated JDK-8289607 to remove the last usages of Thread.suspend/resume from the hotspot tests so I've refreshed this PR to drop the temporary excluding of these tests.

@AlanBateman
Copy link
Contributor Author

Wakeup bot

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Sep 27, 2022
@openjdk
Copy link

openjdk bot commented Sep 27, 2022

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

8249627: Degrade Thread.suspend and Thread.resume

Reviewed-by: cjplummer, sspitsyn, dholmes, jpai

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

  • bc12e95: 8292969: Bad Thread Utilization in ForkJoinPool
  • dd51f7e: 8293996: C2: fix and simplify IdealLoopTree::do_remove_empty_loop
  • 14c6ac4: 8293998: [PPC64] JfrGetCallTrace: assert(_pc != nullptr) failed: must have PC
  • 02ea338: 8293887: AArch64 build failure with GCC 12 due to maybe-uninitialized warning in libfdlibm k_rem_pio2.c
  • 49a7347: 8294408: Problemlist runtime/handshake/HandshakeSuspendExitTest.java
  • aa48705: 8289422: Fix and re-enable vector conditional move
  • 1ddc92f: 8294404: [BACKOUT] JDK-8294142: make test should report only executed tests
  • 1e222bc: 8293462: [macos] app image signature invalid when creating DMG or PKG from post processed signed image
  • 43eff2b: 8272687: Replace StringBuffer with StringBuilder in RuleBasedCollator
  • b88ee1e: 6251738: Want a top-level summary page that itemizes all spec documents referenced from javadocs (OEM spec)
  • ... and 10 more: https://git.openjdk.org/jdk/compare/543851db926469df57a8f4a2bd3458349012145f...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 Sep 27, 2022
@AlanBateman
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Sep 27, 2022

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

  • bc12e95: 8292969: Bad Thread Utilization in ForkJoinPool
  • dd51f7e: 8293996: C2: fix and simplify IdealLoopTree::do_remove_empty_loop
  • 14c6ac4: 8293998: [PPC64] JfrGetCallTrace: assert(_pc != nullptr) failed: must have PC
  • 02ea338: 8293887: AArch64 build failure with GCC 12 due to maybe-uninitialized warning in libfdlibm k_rem_pio2.c
  • 49a7347: 8294408: Problemlist runtime/handshake/HandshakeSuspendExitTest.java
  • aa48705: 8289422: Fix and re-enable vector conditional move
  • 1ddc92f: 8294404: [BACKOUT] JDK-8294142: make test should report only executed tests
  • 1e222bc: 8293462: [macos] app image signature invalid when creating DMG or PKG from post processed signed image
  • 43eff2b: 8272687: Replace StringBuffer with StringBuilder in RuleBasedCollator
  • b88ee1e: 6251738: Want a top-level summary page that itemizes all spec documents referenced from javadocs (OEM spec)
  • ... and 10 more: https://git.openjdk.org/jdk/compare/543851db926469df57a8f4a2bd3458349012145f...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Sep 27, 2022

@AlanBateman Pushed as commit 1abf971.

💡 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
core-libs core-libs-dev@openjdk.org hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

6 participants