Skip to content

8274687: JDWP deadlocks if some Java thread reaches wait in blockOnDebuggerSuspend #5849

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

Conversation

reinrich
Copy link
Member

@reinrich reinrich commented Oct 7, 2021

This change fixes deadlocks described in the JBS-bug by:

  • Releasing handlerLock before waiting on threadLock in blockOnDebuggerSuspend()

  • Notifying on threadLock in threadControl_reset()

Also the actions in handleAppResumeBreakpoint() are moved/deferred until
doPendingTasks() runs. This is necessary because an event handler must not
release handlerLock first and foremost because handlers are called while
iterating the handler chain for an event type which is protected by handlerLock
(see #5805)

The first commit delays the cleanup actions after leaving the loop in
debugLoop_run(). It allows to reproduce the deadlock running the dispose003
test with the command

make run-test TEST=test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003

The second commit adds a new test that reproduces the deadlock when calling
threadControl_resumeThread() while a thread is waiting in
blockOnDebuggerSuspend().

The third commit contains the fix described above. With it the deadlocks
cannot be reproduced anymore.

The forth commit removes the diagnostic code introduced with the first commit again.

The fix passed

test/hotspot/jtreg/serviceability/jdwp
test/jdk/com/sun/jdi
test/hotspot/jtreg/vmTestbase/nsk/jdwp
test/hotspot/jtreg/vmTestbase/nsk/jdi


Progress

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

Issue

  • JDK-8274687: JDWP deadlocks if some Java thread reaches wait in blockOnDebuggerSuspend

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5849

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 7, 2021

👋 Welcome back rrich! 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 Oct 7, 2021

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

  • serviceability

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 serviceability serviceability-dev@openjdk.org label Oct 7, 2021
@reinrich reinrich force-pushed the 8274687_jdwp_deadlock_in_blockOnDebuggerSuspend___v2 branch from b59d303 to 8c1b5ce Compare October 7, 2021 14:01
@reinrich reinrich marked this pull request as ready for review October 7, 2021 14:13
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 7, 2021
@mlbridge
Copy link

mlbridge bot commented Oct 7, 2021

@openjdk
Copy link

openjdk bot commented Oct 22, 2021

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

8274687: JDWP deadlocks if some Java thread reaches wait in blockOnDebuggerSuspend

Reviewed-by: cjplummer, sspitsyn, rschmelter

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

  • 55b36c6: 8276825: hotspot/runtime/SelectionResolution test errors
  • 0f23c6a: 8276926: Use String.valueOf() when initializing File.separator and File.pathSeparator
  • a0b8445: 8276846: JDK-8273416 is incomplete for UseSSE=1
  • a3f710e: 8276215: Intrinsics matchers should handle native method flags better
  • 0f463a7: 8276845: (fs) java/nio/file/spi/SetDefaultProvider.java fails on x86_32
  • e01d6d0: 8276679: Malformed Javadoc inline tags in JDK source in javax/swing
  • fd0a25e: 8276805: java/awt/print/PrinterJob/CheckPrivilege.java fails due to disabled SecurityManager
  • 403f318: 8276854: Windows GHA builds fail due to broken Cygwin
  • e91e9d8: 8276721: G1: Refine G1EvacFailureObjectsSet::iterate
  • 8822d41: 8274736: Concurrent read/close of SSLSockets causes SSLSessions to be invalidated unnecessarily
  • ... and 431 more: https://git.openjdk.java.net/jdk/compare/29dcbb72a2d9b224203d92ad3224cf149a7d08de...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 Oct 22, 2021
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.

Hi Richard,
The fix looks okay to me.
I've inlined one minor suggestion.
Thanks,
Serguei

*/
debugMonitorExit(threadLock);
eventHandler_lock();
debugMonitorEnter(threadLock);
Copy link
Contributor

Choose a reason for hiding this comment

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

The lines 2192-2194 look like a hack to me.
But I see you have filed an enhancement to fix this.
I'm okay to address it later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for looking at this Serguei.
I agree that this part looks a little odd. It is still correct, though, and the changes are limited to the hardly used code responsible for handling j.l.Thread.resume() calls which is a good thing IMHO.

Copy link
Contributor

@schmelter-sap schmelter-sap left a comment

Choose a reason for hiding this comment

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

LGTM

@reinrich
Copy link
Member Author

Thanks for the reviews @plummercj, @sspitsyn, @schmelter-sap!

/integrate

@openjdk
Copy link

openjdk bot commented Nov 15, 2021

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

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Nov 15, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 15, 2021
@openjdk
Copy link

openjdk bot commented Nov 15, 2021

@reinrich Pushed as commit ca2efb7.

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

@reinrich reinrich deleted the 8274687_jdwp_deadlock_in_blockOnDebuggerSuspend___v2 branch October 20, 2022 06:28
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
Development

Successfully merging this pull request may close these issues.

4 participants