Skip to content

Commit

Permalink
8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears…
Browse files Browse the repository at this point in the history
… to be hung"

Reviewed-by: amenkov, lmesnik, sspitsyn, dcubed
  • Loading branch information
plummercj committed Mar 21, 2023
1 parent 019fcd8 commit 0deb648
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 0 additions & 2 deletions test/jdk/ProblemList-svc-vthread.txt
Expand Up @@ -54,8 +54,6 @@ com/sun/jdi/StepTest.java 8285422 generic-all
com/sun/jdi/redefine/RedefineTest.java 8285422 generic-all
com/sun/jdi/redefineMethod/RedefineTest.java 8285422 generic-all

com/sun/jdi/InvokeHangTest.java 8290200 macosx-x64,windows-x64

####
# JDI SDE Tests
# Use custom classpath
Expand Down
24 changes: 18 additions & 6 deletions test/jdk/com/sun/jdi/InvokeHangTest.java
Expand Up @@ -59,11 +59,23 @@ public static void main(String[] args) {

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

try {
// The join ensures that the test completes before we exit main(). If we are using
// virtual threads, they are always daemon threads, and therefore the JVM will exit
// while they are still running (and the test has not yet completed). The join
// isn't really needed for platform threads, since by default they are not
// daemon threads, but it doesn't hurt any either.
t1.join();
t2.join();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}

// This is called from the debugger via invokeMethod
public double invokeee() {
System.out.println("Debuggee: invokeee in thread "+Thread.currentThread().toString());
System.out.println("Debuggee: invokeee in thread " + Thread.currentThread().toString());
Thread.yield();
return longMethod(2);
}
Expand Down Expand Up @@ -145,9 +157,9 @@ void doInvoke(ThreadReference thread, ObjectReference ref, String methodName) {
List methods = ref.referenceType().methodsByName(methodName);
Method method = (Method) methods.get(0);
try {
System.err.println(" Debugger: Invoking in thread" + thread);
System.out.println(" Debugger: Invoking in thread " + thread);
ref.invokeMethod(thread, method, new ArrayList(), ref.INVOKE_NONVIRTUAL);
System.err.println(" Debugger: Invoke done");
System.out.println(" Debugger: Invoke done");
} catch (Exception ex) {
ex.printStackTrace();
failure("failure: Exception");
Expand Down Expand Up @@ -191,7 +203,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());
doInvoke(thread, sf.thisObject(), "invokeee");
} catch (IncompatibleThreadStateException itsex) {
itsex.printStackTrace();
Expand All @@ -214,7 +226,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();

/*
* Set event requests
Expand Down Expand Up @@ -246,7 +258,7 @@ public void run() {
vmDisconnected = true;
// This awakens the main thread which is
// waiting for a VMDisconnect.
mainThread.interrupt();
mainTestThread.interrupt();
break;
}
myBkpts = bkpts;
Expand Down

1 comment on commit 0deb648

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.