1 #!/bin/sh 2 3 # 4 # Copyright (c) 2005, 2015 Oracle and/or its affiliates. All rights reserved. 5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 # 7 # This code is free software; you can redistribute it and/or modify it 8 # under the terms of the GNU General Public License version 2 only, as 9 # published by the Free Software Foundation. 10 # 11 # This code is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 # version 2 for more details (a copy is included in the LICENSE file that 15 # accompanied this code). 16 # 17 # You should have received a copy of the GNU General Public License version 18 # 2 along with this work; if not, write to the Free Software Foundation, 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 # or visit www.oracle.com if you need additional information or have any 23 # questions. 24 # 25 26 # @test 27 # @bug 6224859 28 # @summary JDWP: Mixing application suspends and debugger suspends can cause hangs 29 # 30 # @author Jim Holmlund 31 # 32 # @modules jdk.jdi 33 # @run build TestScaffold VMConnection TargetListener TargetAdapter 34 # @run shell MixedSuspendTest.sh 35 36 classname=MixedSuspendTarg 37 38 createJavaFile() 39 { 40 cat <<EOF > $classname.java.1 41 42 import java.util.*; 43 44 public class $classname extends Thread { 45 46 static volatile boolean started = true; 47 static String lock = "startLock"; 48 49 public static void main(String[] args){ 50 System.out.println("Howdy from MixedSuspendTarg"); 51 52 MixedSuspendTarg mytarg = new MixedSuspendTarg(); 53 54 synchronized(lock) { 55 mytarg.start(); 56 try { 57 lock.wait(); 58 } catch(InterruptedException ee) { 59 } 60 } 61 mytarg.suspend(); 62 bkpt(); 63 System.out.println("Debuggee: resuming thread"); 64 65 // If the bug occurs, this resume hangs in the back-end 66 mytarg.resume(); 67 System.out.println("Debuggee: resumed thread"); 68 synchronized(lock) { 69 started = false; 70 } 71 System.out.println("Debuggee: exitting, started = " + started); 72 } 73 74 public void run() { 75 synchronized(lock) { 76 lock.notifyAll(); 77 } 78 while (true) { 79 synchronized(lock) { 80 if (!started) { 81 break; 82 } 83 int i = 0; 84 } 85 } 86 87 System.out.println("Debuggee: end of thread"); 88 } 89 90 static void bkpt() { 91 //System.out.println("bkpt reached, thread = " + this.getName()); 92 int i = 0; // @1 breakpoint 93 } 94 } 95 96 EOF 97 } 98 99 dojdbCmds() 100 { 101 setBkpts @1 102 runToBkpt @1 103 cmd allowExit cont 104 } 105 106 107 mysetup() 108 { 109 if [ -z "$TESTSRC" ] ; then 110 TESTSRC=. 111 fi 112 113 for ii in . $TESTSRC $TESTSRC/.. ; do 114 if [ -r "$ii/ShellScaffold.sh" ] ; then 115 . $ii/ShellScaffold.sh 116 break 117 fi 118 done 119 } 120 121 # You could replace this next line with the contents 122 # of ShellScaffold.sh and this script will run just the same. 123 mysetup 124 125 runit 126 ## This test fails by timing out. 127 pass