/*
* Copyright (c) 2003, 2018, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @key stress
*
* @summary converted from VM testbase nsk/stress/strace/strace005.
* VM testbase keywords: [stress, strace]
* VM testbase readme:
* DESCRIPTION
* The test checks up java.lang.Thread.getStackTrace() method for many threads,
* that recursively invoke pure java and native methods by turns in running
* mode ("alive" stack).
* The test fails if:
* - amount of stack trace elements is more than depth of recursion plus
* four elements corresponding to invocations of Thread.run(), Thread.wait(),
* Thread.exit(), Thread.yield() and ThreadGroup.remove() methods;
* - there is at least one element corresponding to invocation of unexpected
* method.
* This test is almost the same as nsk.stress.strace.strace001 and
* nsk.stress.strace.strace003 except for the recursive methods are
* pure java and native one.
* COMMENTS
* Below assertion is revealed on engineer's build. It is needed to check
* on a promoted build.
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* waiting for all threads started ...
* Unexpected Signal : 11 occurred at PC=0xFDBB7820
* Function=[Unknown. Nearest: SUNWprivate_1.1+0x3B7820]
* Library=java/vitp/jdk/4593133/solaris-sparc/jre/lib/sparc/client/libjvm.so
* Current Java thread:
* at nsk.stress.strace.strace005Thread.recursiveMethod2(Native Method)
* at nsk.stress.strace.strace005Thread.recursiveMethod1(strace005.java:285)
* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
* at nsk.stress.strace.strace005Thread.recursiveMethod2(Native Method)
* at nsk.stress.strace.strace005Thread.recursiveMethod1(strace005.java:285)
* at nsk.stress.strace.strace005Thread.recursiveMethod2(Native Method)
* Dynamic libraries:
* 0x10000 jdk/4593133/solaris-sparc/bin/java
* 0xff350000 /usr/lib/libthread.so.1
* 0xff390000 /usr/lib/libdl.so.1
* 0xff200000 /usr/lib/libc.so.1
* 0xff330000 /usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1
* 0xfd800000 java/vitp/jdk/4593133/solaris-sparc/jre/lib/sparc/client/libjvm.so
* 0xff2d0000 /usr/lib/libCrun.so.1
* 0xff1d0000 /usr/lib/libsocket.so.1
* 0xff100000 /usr/lib/libnsl.so.1
* 0xff0d0000 /usr/lib/libm.so.1
* 0xff0b0000 /usr/lib/libsched.so.1
* 0xff300000 /usr/lib/libw.so.1
* 0xff090000 /usr/lib/libmp.so.2
* 0xff050000 java/vitp/jdk/4593133/solaris-sparc/jre/lib/sparc/native_threads/libhpi.so
* 0xfd7d0000 java/vitp/jdk/4593133/solaris-sparc/jre/lib/sparc/libverify.so
* 0xfd790000 java/vitp/jdk/4593133/solaris-sparc/jre/lib/sparc/libjava.so
* 0xfe7e0000 java/vitp/jdk/4593133/solaris-sparc/jre/lib/sparc/libzip.so
* 0xfc6e0000 java/vitp/tests/4593133/src/libstrace005.so
* Heap at VM Abort:
* Heap
* def new generation total 2112K, used 336K [0xf1800000, 0xf1a20000, 0xf1f10000)
* eden space 2048K, 16% used [0xf1800000, 0xf1854300, 0xf1a00000)
* from space 64K, 0% used [0xf1a00000, 0xf1a00000, 0xf1a10000)
* to space 64K, 0% used [0xf1a10000, 0xf1a10000, 0xf1a20000)
* tenured generation total 1408K, used 0K [0xf1f10000, 0xf2070000, 0xf5800000)
* the space 1408K, 0% used [0xf1f10000, 0xf1f10000, 0xf1f10200, 0xf2070000)
* compacting perm gen total 4096K, used 1020K [0xf5800000, 0xf5c00000, 0xf9800000)
* the space 4096K, 24% used [0xf5800000, 0xf58ff028, 0xf58ff200, 0xf5c00000)
* Local Time = Fri Apr 25 18:09:16 2003
* Elapsed Time = 13
* #
* # HotSpot Virtual Machine Error : 11
* # Error ID : src/share/vm/runtime/os.cpp, 753 [ Patched ]
* # Please report this error at
* # http://java.sun.com/cgi-bin/bugreport.cgi
* #
* # Java VM: Java HotSpot(TM) Client VM (1.4.1-internal-debug mixed mode)
* #
* # An error report file has been saved as hs_err_pid16847.log.
* # Please refer to the file for further information.
* #
* Dumping core....
* Abort
* Finished at: Fri Apr 25 18:09:17 NSK 2003
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/native nsk.stress.strace.strace005
*/
package nsk.stress.strace;
import nsk.share.ArgumentParser;
import nsk.share.Failure;
import nsk.share.Log;
import java.io.PrintStream;
/**
* The test checks up java.lang.Thread.getStackTrace()
method for many threads,
* that recursively invoke pure java and native methods by turns in running mode
* ("alive" stack).
*
*
The test creates THRD_COUNT
instances of strace005Thread
* class, tries to get their stack traces and checks up that returned array contains
* correct stack frames. Each stack frame must be corresponded to one of the following
* methods defined by the EXPECTED_METHODS
array.
These checking are performed REPEAT_COUNT
times.
strace005Thread
class and tries
* to get their stack traces.
*/
class strace005Thread extends Thread {
private int currentDepth = 0;
public boolean isNativeResolved = false;
strace005 test;
static {
try {
System.loadLibrary("strace005");
} catch (UnsatisfiedLinkError e) {
System.err.println("Could not load strace005 library");
System.err.println("java.library.path:"
+ System.getProperty("java.library.path"));
throw e;
}
}
strace005Thread(strace005 test, String name) {
this.test = test;
setName(name);
}
public void run() {
recursiveMethod1();
}
void recursiveMethod1() {
currentDepth++;
if (currentDepth == 1) {
synchronized (test) {
test.achivedCount++;
}
int alltime = 0;
while (!strace005.isLocked) {
synchronized (test) {
try {
test.wait(1);
alltime++;
} catch (InterruptedException e) {
strace005.complain("" + e);
}
if (alltime > strace005.waitTime) {
throw new Failure("out of wait time");
}
}
}
} else if (currentDepth > 1 && !isNativeResolved)
isNativeResolved = true;
if (strace005.DEPTH - currentDepth > 0) {
try {
yield();
recursiveMethod2();
} catch (StackOverflowError e) {
// ignore this exception
}
}
currentDepth--;
}
native void recursiveMethod2();
}