4903717: nsk/jdi/ThreadReference/isSuspended/issuspended002 failing

Reviewed-by: amenkov, sspitsyn
This commit is contained in:
Gary Adams 2019-03-04 08:45:05 -05:00
parent 3d9de2e6f2
commit cf086be753
2 changed files with 64 additions and 43 deletions

View File

@ -157,7 +157,6 @@ vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded004
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded005/TestDescription.java 8153598 generic-all
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock001/TestDescription.java 8060733 generic-all
vmTestbase/nsk/jdi/ThreadReference/isSuspended/issuspended002/TestDescription.java 4903717 generic-all
vmTestbase/nsk/jdi/ThreadReference/resume/resume001/TestDescription.java 8072701 generic-all
vmTestbase/nsk/jdi/ThreadReference/stop/stop001/TestDescription.java 7034630 generic-all
vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x001/TestDescription.java 8013728 generic-all

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -63,8 +63,8 @@ public class issuspended002a {
public static void main (String argv[]) {
for (int i=0; i<argv.length; i++) {
if ( argv[i].equals("-vbs") || argv[i].equals("-verbose") ) {
for (int i = 0; i < argv.length; i++) {
if (argv[i].equals("-vbs") || argv[i].equals("-verbose")) {
verbMode = true;
break;
}
@ -76,10 +76,8 @@ public class issuspended002a {
IOPipe pipe = argHandler.createDebugeeIOPipe();
pipe.println("ready");
int exitCode = PASSED;
for (int i = 0; ; i++) {
String instruction;
log1("waiting for an instruction from the debugger ...");
@ -94,53 +92,70 @@ public class issuspended002a {
//------------------------------------------------------ section tested
case 0:
Threadissuspended002a test_thread =
new Threadissuspended002a("testedThread");
log1(" thread2 is created");
Threadissuspended002a test_thread =
new Threadissuspended002a("testedThread");
log1(" thread2 is created");
label:
synchronized (Threadissuspended002a.lockingObject) {
synchronized (Threadissuspended002a.waitnotifyObj) {
log1(" synchronized (waitnotifyObj) { enter");
log1(" before: test_thread.start()");
test_thread.start();
label:
synchronized (Threadissuspended002a.lockingObject) {
synchronized (Threadissuspended002a.waitnotifyObj) {
log1(" synchronized (waitnotifyObj) { enter");
log1(" before: test_thread.start()");
test_thread.start();
try {
log1(" before: waitnotifyObj.wait();");
Threadissuspended002a.waitnotifyObj.wait();
log1(" after: waitnotifyObj.wait();");
pipe.println("checkready");
instruction = pipe.readln();
if (!instruction.equals("continue")) {
logErr("ERROR: unexpected instruction: " + instruction);
exitCode = FAILED;
break label;
}
} catch ( Exception e2) {
log1(" Exception e2 exception: " + e2 );
pipe.println("waitnotifyerr");
}
}
}
log1("mainThread is out of: synchronized (lockingObject) {");
try {
log1(" before: waitnotifyObj.wait();");
Threadissuspended002a.waitnotifyObj.wait();
log1(" after: waitnotifyObj.wait();");
pipe.println("checkready");
instruction = pipe.readln();
if (!instruction.equals("continue")) {
logErr("ERROR: unexpected instruction: " + instruction);
exitCode = FAILED;
break label;
}
pipe.println("docontinue");
} catch ( Exception e2) {
log1(" Exception e2 exception: " + e2 );
pipe.println("waitnotifyerr");
}
}
}
log1("mainThread is out of: synchronized (lockingObject) {");
// To avoid contention for the logging print stream lock
// the main thread will wait until the debuggee test thread
// has completed to the breakpoint.
// If the debugger suspends the main thread while it is holding
// the logging lock, the test is deadlocked on the test thread log
// calls.
synchronized (Threadissuspended002a.waitnotifyObj) {
try {
// Main debuggee thread is out of synchronized(lockingObject)
// so the test thread will continue.
// Send the debugger the "docontinue" command
// so it will enable the breakpoint in the test thread.
pipe.println("docontinue");
break ;
Threadissuspended002a.waitnotifyObj.wait();
} catch (Exception e3) {
pipe.println("waitnotifyerr");
}
}
break ;
//------------------------------------------------- standard end section
default:
pipe.println("checkend");
break ;
pipe.println("checkend");
break ;
}
} else {
logErr("ERRROR: unexpected instruction: " + instruction);
logErr("ERROR: unexpected instruction: " + instruction);
exitCode = FAILED;
break ;
}
}
System.exit(exitCode + PASS_BASE);
}
}
@ -158,12 +173,14 @@ class Threadissuspended002a extends Thread {
public void run() {
log("method 'run' enter");
synchronized (waitnotifyObj) {
synchronized (waitnotifyObj) {
log("entered into block: synchronized (waitnotifyObj)");
waitnotifyObj.notify(); }
waitnotifyObj.notify();
}
log("exited from block: synchronized (waitnotifyObj)");
synchronized (lockingObject) {
log("entered into block: synchronized (lockingObject)"); }
synchronized (lockingObject) {
log("entered into block: synchronized (lockingObject)");
}
log("exited from block: synchronized (lockingObject)");
i1++;
i2--;
@ -171,6 +188,11 @@ class Threadissuspended002a extends Thread {
runt1();
log("returned from the method 'runt1'");
log("method 'run' exit");
// Allow the main thread to continue
synchronized (waitnotifyObj) {
waitnotifyObj.notify();
}
return;
}