Skip to content

8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung" #13068

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 5 commits into from

Conversation

plummercj
Copy link
Contributor

@plummercj plummercj commented Mar 16, 2023

The debuggee main method creates two threads and then starts them:

    public static void main(String[] args) {
        System.out.println("Howdy!");
        Thread t1 = TestScaffold.newThread(new InvokeHangTarg(), name1);
        Thread t2 = TestScaffold.newThread(new InvokeHangTarg(), name2);

        t1.start();
        t2.start();
    }

These threads will hit breakpoints which the debugger handles and issues an invoke on the breakpoint thread. The threads run until they generate 100 breakpoints. There is an issue when these two threads are virtual threads. Virtual threads are daemon threads. That means the JVM can exit while they are still running. The above main() method is not waiting for these two threads to exit, so main() exits immediately and the JVM starts the shutdown process. It first must wait for all non-daemon threads to exit, but there are none, so the JVM exits right away before the two threads are completed. The end result of this early exit is that sometimes the invoke done by the debugger never completes because the JVM has already issued a VMDeath event and the debuggee has been disconnected.

When these two threads are platform threads, the JVM has to wait until they complete before it exits, so they will always complete. The fix for virtual threads is to do a join with t1 and t2. This forces the main() method to block until they have completed.


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-8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung"

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13068

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 16, 2023

👋 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.

@@ -214,7 +220,7 @@ protected void runTests() throws Exception {
targetClass = bpe.location().declaringType();
mainThread = bpe.thread();
EventRequestManager erm = vm().eventRequestManager();
final Thread mainThread = Thread.currentThread();
final Thread mainTestThread = Thread.currentThread();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This local variable was conflicting with an instance field of the same name. See line 135. I ran into issues when I added some debugging code to this method that referenced the other mainThread, so I did a rename.

@openjdk openjdk bot changed the title 8290200 8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung" Mar 16, 2023
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 16, 2023
@openjdk
Copy link

openjdk bot commented Mar 16, 2023

@plummercj 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 Mar 16, 2023
@mlbridge
Copy link

mlbridge bot commented Mar 16, 2023

Webrevs

@@ -191,7 +197,7 @@ public void breakpointReached(BreakpointEvent event) {
ThreadReference thread = event.thread();
try {
StackFrame sf = thread.frame(0);
System.err.println(" Debugger: Breakpoint hit at "+sf.location());
System.out.println(" Debugger: Breakpoint hit at "+sf.location());

Choose a reason for hiding this comment

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

while you are here please add spaces around plus

@openjdk
Copy link

openjdk bot commented Mar 16, 2023

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

8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung"

Reviewed-by: amenkov, lmesnik, sspitsyn, dcubed

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

  • f8482c2: 8297638: Memory leak in case of many started-dead threads
  • c56f011: 8298995: tools/jpackage/share/AddLauncherTest.java#id1 failed "AddLauncherTest.test; checks=53"
  • 254288a: 8014021: TreeMaker.Params behaves inconsistently when the owning method has the same number of parameters as the number of parameter types requested
  • 8f5bb53: 8015831: Add lint check for calling overridable methods from a constructor
  • b085ab9: 8180387: com.sun.source.util.JavacTask should have a protected constructor.
  • bfb812a: 8292818: replace 96-bit representation for field metadata with variable-sized streams
  • 932be35: 8298469: Obsolete legacy parallel class loading workaround for non-parallel-capable class loaders
  • 02a4ee2: 8303921: serviceability/sa/UniqueVtableTest.java timed out
  • 4486f1b: 8304367: jlink --include-locales=* attempts to parse non .class resource files with classfile reader
  • 8d2ebf2: 8303697: ProcessTools doesn't print last line of process output
  • ... and 59 more: https://git.openjdk.org/jdk/compare/7bbc5e0efbcbf97e8c1d4e889bd06c33c5f4eaa5...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 Mar 16, 2023
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

Comment on lines 62 to 67
try {
t1.join();
t2.join();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Copy link
Member

Choose a reason for hiding this comment

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

Please consider adding a comment that explains that the join() calls
are only necessary when t1 and t2 are virtual threads.

Copy link
Member

@dcubed-ojdk dcubed-ojdk left a comment

Choose a reason for hiding this comment

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

Thumbs up. Thanks for adding the comment.
One possible nit typo...


try {
// The join ensures that the test completes before we exit main(). If we are using
// virtual threads, they are always daemon threads, and therefor the JVM will exit
Copy link
Member

Choose a reason for hiding this comment

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

nit typo: s/therefor/therefore/

@plummercj
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Mar 21, 2023

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

  • 019fcd8: 8304139: Add and method constants to ConstantDescs
  • d6f20e2: 8304680: Problemlist compiler/sharedstubs/SharedStubToInterpTest.java
  • d788a1b: 8304180: Constant Descriptors for MethodHandles::classData and classDataAt
  • bbde215: 8299494: Test vmTestbase/nsk/stress/except/except011.java failed: ExceptionInInitializerError: target class not found
  • 1c04686: 8304387: Fix positions of shared static stubs / trampolines
  • c65bb2c: 8304334: java/awt/color/ICC_ColorSpace/ToFromCIEXYZRoundTrip.java times out on slow platforms
  • 4bf1fbb: 8303648: Add String.indexOf(String str, int beginIndex, int endIndex)
  • c4df9b5: 8304537: Ant-based langtools build fails after JDK-8015831 Add lint check for calling overridable methods from a constructor
  • a6b72f5: 8304230: LShift ideal transform assertion
  • a72ba38: 8303948: HsErrFileUtils.checkHsErrFileContent() fails to check the last pattern.
  • ... and 88 more: https://git.openjdk.org/jdk/compare/7bbc5e0efbcbf97e8c1d4e889bd06c33c5f4eaa5...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Mar 21, 2023

@plummercj Pushed as commit 0deb648.

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

Successfully merging this pull request may close these issues.

5 participants