Mercurial > hg > release > heapstats-2.1
changeset 227:f421a4c6e7ea
Bug 3357: [TEST][RaceCondition]Add some events with ClassPrepare
Reviewed-by: yasuenag
https://github.com/HeapStats/heapstats/pull/92
line wrap: on
line diff
--- a/ChangeLog Tue Apr 11 17:38:38 2017 +0900 +++ b/ChangeLog Tue Apr 11 18:05:01 2017 +0900 @@ -4,6 +4,7 @@ * Bug 3354: [TEST]Modify test runners for testing in a similar way * Bug 3355: [TEST]Add unit test cases * Bug 3356: [TEST]Add a race-condition test framework + * Bug 3357: [TEST][RaceCondition]Add some events with ClassPrepare 2017-03-25 KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ClassPrepare/buildenv.sh Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,10 @@ +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +unset JAVA_OPTS +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/dynload/DynLoad.java +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ClassPrepare/test.py Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,12 @@ +import sys, os +sys.path.append(os.pardir + "/../") + +import common + +def Cond_OnClassPrepare(): + gdb.newest_frame().older().select() + symbol = gdb.execute("p (char *)klass->_name->_body", False, True) + return (symbol.find("DynLoad") != -1) + + +common.initialize("OnClassPrepare", Cond_OnClassPrepare, "OnClassPrepare", Cond_OnClassPrepare, False)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ClassPrepare/testcase/Test.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,27 @@ +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; + +public class Test implements Runnable{ + + public void run(){ + try{ + ClassLoader loader = new URLClassLoader(new URL[]{ + Paths.get(System.getProperty("java.class.path"), "dynload") + .toUri() + .toURL()}); + Class<?> target = loader.loadClass("DynLoad"); + Method targetMethod = target.getMethod("call"); + Object targetObj = target.newInstance(); + targetMethod.invoke(targetObj); + } + catch(Exception e){ + e.printStackTrace(); + } + } + + public static void main(String[] args) throws Exception{ + (new Thread(new Test())).start(); + (new Thread(new Test())).start(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ClassPrepare/testcase/dynload/DynLoad.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,5 @@ +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/DataDumpRequest/buildenv.sh Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,10 @@ +#!/bin/sh + +export CLASSPATH="$JAVA_HOME/lib/tools.jar:testcase" +export MAINCLASS=Test +unset JAVA_OPTS +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac -cp $CLASSPATH $TEST_TARGET/testcase/Test.java +$JAVA_HOME/bin/javac -cp $CLASSPATH $TEST_TARGET/testcase/dynload/DynLoad.java +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/DataDumpRequest/test.py Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,32 @@ +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +def Cond_OnClassPrepare(): + gdb.newest_frame().older().select() + symbol = gdb.execute("p (char *)klass->_name->_body", False, True) + return (symbol.find("DynLoad") != -1) + + +class BreakAtDataDump(gdb.Breakpoint): + def __init__(self): + super(BreakAtDataDump, self).__init__("data_dump") + + def stop(self): + gdb.execute("set var ReduceSignalUsage=true") + gdb.write("set true to ReduceSignalUsage\n") + + +class BreakAtShouldPostDataDump(gdb.Breakpoint): + def __init__(self): + super(BreakAtShouldPostDataDump, self).__init__("JvmtiExport::should_post_data_dump") + + def stop(self): + gdb.execute("set var ReduceSignalUsage=false") + gdb.write("set false to ReduceSignalUsage\n") + + +common.initialize("OnClassPrepare", Cond_OnClassPrepare, "OnDataDumpRequestForSnapShot", common.return_true, True) +BreakAtDataDump() +BreakAtShouldPostDataDump()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/DataDumpRequest/testcase/Test.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,44 @@ +import java.util.stream.*; +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import com.sun.tools.attach.*; +import sun.tools.attach.*; + +public class Test implements Runnable{ + + public void run(){ + try{ + String cp = Stream.of(System.getProperty("java.class.path").split(":")) + .filter(p -> !p.contains("tools.jar")) + .findAny() + .get(); + ClassLoader loader = new URLClassLoader(new URL[]{Paths.get(cp, "dynload") + .toUri() + .toURL()}); + Class<?> target = loader.loadClass("DynLoad"); + Method targetMethod = target.getMethod("call"); + Object targetObj = target.newInstance(); + targetMethod.invoke(targetObj); + } + catch(Exception e){ + e.printStackTrace(); + } + } + + public static void main(String[] args) throws Exception{ + (new Thread(new Test())).start(); + + Path selfProc = Paths.get("/proc/self"); + String pid = Files.readSymbolicLink(selfProc).toString(); + HotSpotVirtualMachine selfVM = + (HotSpotVirtualMachine)VirtualMachine.attach(pid); + try{ + selfVM.localDataDump(); + } + finally{ + selfVM.detach(); + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/DataDumpRequest/testcase/dynload/DynLoad.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,5 @@ +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MemoryExhausted/buildenv.sh Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,10 @@ +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-Xmx500m" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/dynload/DynLoad.java +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MemoryExhausted/test.py Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,12 @@ +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +def Cond_OnClassPrepare(): + gdb.newest_frame().older().select() + symbol = gdb.execute("p (char *)klass->_name->_body", False, True) + return (symbol.find("DynLoad") != -1) + + +common.initialize("OnClassPrepare", Cond_OnClassPrepare, "OnResourceExhausted", common.return_true, True)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MemoryExhausted/testcase/Test.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,37 @@ +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + public static void runClassLoad(){ + try{ + ClassLoader loader = new URLClassLoader(new URL[]{ + Paths.get(System.getProperty("java.class.path"), "dynload") + .toUri() + .toURL()}); + Class<?> target = loader.loadClass("DynLoad"); + Method targetMethod = target.getMethod("call"); + Object targetObj = target.newInstance(); + targetMethod.invoke(targetObj); + } + catch(Exception e){ + e.printStackTrace(); + } + } + + public static void runMemleak(){ + List<byte[]> list = new ArrayList<>(); + + while(true){ + list.add(new byte[1024*1024]); + } + } + + public static void main(String[] args){ + (new Thread(Test::runMemleak)).start(); + (new Thread(Test::runClassLoad)).start(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MemoryExhausted/testcase/dynload/DynLoad.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,5 @@ +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEnter/buildenv.sh Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,9 @@ +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +unset JAVA_OPTS +export HEAPSTATS_CONF=heapstats-threadrecorder.conf + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/dynload/DynLoad.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEnter/heapstats-threadrecorder.conf Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,70 @@ +# HeapStats 2.0.trunk +# HeapStats 2.0.trunk configuration file. +attach=true + +# Output file setting +file=heapstats_snapshot.dat +heaplogfile=heapstats_log.csv +archivefile=heapstats_analyze.zip +logfile= +loglevel=INFO +reduce_snapshot=true + +# SnapShot type +collect_reftree=true + +# Trigger snapshot setting +trigger_on_fullgc=true +trigger_on_dump=true + +# deadlock check +# This feature is experimental. It might be a cause of HotSpot internal error +# when you set this flag to true. +check_deadlock=false + +# Trigger logging setting +trigger_on_logerror=true +trigger_on_logsignal=true +trigger_on_loglock=true + +# Rank setting +rank_level=5 +rank_order=delta + +# Alert setting +alert_percentage=50 + +# Alert threshold for java heap usage. +# "0" means disabled. +javaheap_alert_percentage=95 + +# Alert threshold for metaspace usage (in MB). +# "0" means disabled. +metaspace_alert_threshold=0 + +# Timer setting +snapshot_interval=0 +log_interval=300 + +first_collect=true +logsignal_normal= +logsignal_all=SIGUSR2 +signal_reload=SIGHUP + +# Thread recording +thread_record_enable=true +thread_record_buffer_size=100 # Set buffer size in MB. +thread_record_filename=heapstats_thread-records.htr +#thread_record_iotracer=/usr/local/etc/iotracer/IoTrace.class + +# Snmp setting +snmp_send=false +snmp_target=localhost +snmp_comname=public +# You can check library path with `net-snmp-config --netsnmp-libs` +snmp_libpath=/usr/lib64/libnetsnmp.so + +logdir=./tmp +archive_command=/usr/bin/zip %archivefile% -jr %logdir% + +kill_on_error=false
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEnter/test.py Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,12 @@ +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +def Cond_OnClassPrepare(): + gdb.newest_frame().older().select() + symbol = gdb.execute("p (char *)klass->_name->_body", False, True) + return (symbol.find("DynLoad") != -1) + + +common.initialize("OnClassPrepare", Cond_OnClassPrepare, "OnMonitorContendedEnterForThreadRecording", common.return_true, True)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEnter/testcase/Test.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,33 @@ +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; + + +public class Test implements Runnable{ + + public void run(){ + try{ + synchronized(Test.class){ + System.out.println("Sleep at " + Thread.currentThread().getName()); + Thread.sleep(3000); + } + } + catch(InterruptedException e){ + e.printStackTrace(); + } + } + + public static void main(String[] args) throws Exception{ + (new Thread(new Test())).start(); + (new Thread(new Test())).start(); + + ClassLoader loader = new URLClassLoader(new URL[]{ + Paths.get(System.getProperty("java.class.path"), "dynload") + .toUri() + .toURL()}); + Class<?> target = loader.loadClass("DynLoad"); + Method targetMethod = target.getMethod("call"); + Object targetObj = target.newInstance(); + targetMethod.invoke(targetObj); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEnter/testcase/dynload/DynLoad.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,5 @@ +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEntered/buildenv.sh Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,9 @@ +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +unset JAVA_OPTS +export HEAPSTATS_CONF=heapstats-threadrecorder.conf + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/dynload/DynLoad.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEntered/heapstats-threadrecorder.conf Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,70 @@ +# HeapStats 2.0.trunk +# HeapStats 2.0.trunk configuration file. +attach=true + +# Output file setting +file=heapstats_snapshot.dat +heaplogfile=heapstats_log.csv +archivefile=heapstats_analyze.zip +logfile= +loglevel=INFO +reduce_snapshot=true + +# SnapShot type +collect_reftree=true + +# Trigger snapshot setting +trigger_on_fullgc=true +trigger_on_dump=true + +# deadlock check +# This feature is experimental. It might be a cause of HotSpot internal error +# when you set this flag to true. +check_deadlock=false + +# Trigger logging setting +trigger_on_logerror=true +trigger_on_logsignal=true +trigger_on_loglock=true + +# Rank setting +rank_level=5 +rank_order=delta + +# Alert setting +alert_percentage=50 + +# Alert threshold for java heap usage. +# "0" means disabled. +javaheap_alert_percentage=95 + +# Alert threshold for metaspace usage (in MB). +# "0" means disabled. +metaspace_alert_threshold=0 + +# Timer setting +snapshot_interval=0 +log_interval=300 + +first_collect=true +logsignal_normal= +logsignal_all=SIGUSR2 +signal_reload=SIGHUP + +# Thread recording +thread_record_enable=true +thread_record_buffer_size=100 # Set buffer size in MB. +thread_record_filename=heapstats_thread-records.htr +#thread_record_iotracer=/usr/local/etc/iotracer/IoTrace.class + +# Snmp setting +snmp_send=false +snmp_target=localhost +snmp_comname=public +# You can check library path with `net-snmp-config --netsnmp-libs` +snmp_libpath=/usr/lib64/libnetsnmp.so + +logdir=./tmp +archive_command=/usr/bin/zip %archivefile% -jr %logdir% + +kill_on_error=false
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEntered/test.py Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,12 @@ +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +def Cond_OnClassPrepare(): + gdb.newest_frame().older().select() + symbol = gdb.execute("p (char *)klass->_name->_body", False, True) + return (symbol.find("DynLoad") != -1) + + +common.initialize("OnClassPrepare", Cond_OnClassPrepare, "OnMonitorContendedEnteredForThreadRecording", common.return_true, True)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEntered/testcase/Test.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,33 @@ +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; + + +public class Test implements Runnable{ + + public void run(){ + try{ + synchronized(Test.class){ + System.out.println("Sleep at " + Thread.currentThread().getName()); + Thread.sleep(3000); + } + } + catch(InterruptedException e){ + e.printStackTrace(); + } + } + + public static void main(String[] args) throws Exception{ + (new Thread(new Test())).start(); + (new Thread(new Test())).start(); + + ClassLoader loader = new URLClassLoader(new URL[]{ + Paths.get(System.getProperty("java.class.path"), "dynload") + .toUri() + .toURL()}); + Class<?> target = loader.loadClass("DynLoad"); + Method targetMethod = target.getMethod("call"); + Object targetObj = target.newInstance(); + targetMethod.invoke(targetObj); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEntered/testcase/dynload/DynLoad.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,5 @@ +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorWait/buildenv.sh Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,10 @@ +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +unset JAVA_OPTS +export HEAPSTATS_CONF=heapstats-threadrecorder.conf + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/dynload/DynLoad.java +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorWait/heapstats-threadrecorder.conf Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,70 @@ +# HeapStats 2.0.trunk +# HeapStats 2.0.trunk configuration file. +attach=true + +# Output file setting +file=heapstats_snapshot.dat +heaplogfile=heapstats_log.csv +archivefile=heapstats_analyze.zip +logfile= +loglevel=INFO +reduce_snapshot=true + +# SnapShot type +collect_reftree=true + +# Trigger snapshot setting +trigger_on_fullgc=true +trigger_on_dump=true + +# deadlock check +# This feature is experimental. It might be a cause of HotSpot internal error +# when you set this flag to true. +check_deadlock=false + +# Trigger logging setting +trigger_on_logerror=true +trigger_on_logsignal=true +trigger_on_loglock=true + +# Rank setting +rank_level=5 +rank_order=delta + +# Alert setting +alert_percentage=50 + +# Alert threshold for java heap usage. +# "0" means disabled. +javaheap_alert_percentage=95 + +# Alert threshold for metaspace usage (in MB). +# "0" means disabled. +metaspace_alert_threshold=0 + +# Timer setting +snapshot_interval=0 +log_interval=300 + +first_collect=true +logsignal_normal= +logsignal_all=SIGUSR2 +signal_reload=SIGHUP + +# Thread recording +thread_record_enable=true +thread_record_buffer_size=100 # Set buffer size in MB. +thread_record_filename=heapstats_thread-records.htr +#thread_record_iotracer=/usr/local/etc/iotracer/IoTrace.class + +# Snmp setting +snmp_send=false +snmp_target=localhost +snmp_comname=public +# You can check library path with `net-snmp-config --netsnmp-libs` +snmp_libpath=/usr/lib64/libnetsnmp.so + +logdir=./tmp +archive_command=/usr/bin/zip %archivefile% -jr %logdir% + +kill_on_error=false
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorWait/test.py Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,12 @@ +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +def Cond_OnClassPrepare(): + gdb.newest_frame().older().select() + symbol = gdb.execute("p (char *)klass->_name->_body", False, True) + return (symbol.find("DynLoad") != -1) + + +common.initialize("OnClassPrepare", Cond_OnClassPrepare, "OnMonitorWait", common.return_true, True)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorWait/testcase/Test.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,34 @@ +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; + + +public class Test implements Runnable{ + + public void run(){ + try{ + synchronized(Test.class){ + Test.class.wait(1000); + } + } + catch(IllegalArgumentException | + IllegalMonitorStateException | InterruptedException e){ + e.printStackTrace(); + } + } + + public static void main(String[] args) throws Exception{ + (new Thread(new Test())).start(); + + ClassLoader loader = new URLClassLoader(new URL[]{ + Paths.get(System.getProperty("java.class.path"), "dynload") + .toUri() + .toURL()}); + + Class<?> target = loader.loadClass("DynLoad"); + Method targetMethod = target.getMethod("call"); + Object targetObj = target.newInstance(); + targetMethod.invoke(targetObj); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorWait/testcase/dynload/DynLoad.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,5 @@ +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorWaited/buildenv.sh Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,10 @@ +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +unset JAVA_OPTS +export HEAPSTATS_CONF=heapstats-threadrecorder.conf + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/dynload/DynLoad.java +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorWaited/heapstats-threadrecorder.conf Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,70 @@ +# HeapStats 2.0.trunk +# HeapStats 2.0.trunk configuration file. +attach=true + +# Output file setting +file=heapstats_snapshot.dat +heaplogfile=heapstats_log.csv +archivefile=heapstats_analyze.zip +logfile= +loglevel=INFO +reduce_snapshot=true + +# SnapShot type +collect_reftree=true + +# Trigger snapshot setting +trigger_on_fullgc=true +trigger_on_dump=true + +# deadlock check +# This feature is experimental. It might be a cause of HotSpot internal error +# when you set this flag to true. +check_deadlock=false + +# Trigger logging setting +trigger_on_logerror=true +trigger_on_logsignal=true +trigger_on_loglock=true + +# Rank setting +rank_level=5 +rank_order=delta + +# Alert setting +alert_percentage=50 + +# Alert threshold for java heap usage. +# "0" means disabled. +javaheap_alert_percentage=95 + +# Alert threshold for metaspace usage (in MB). +# "0" means disabled. +metaspace_alert_threshold=0 + +# Timer setting +snapshot_interval=0 +log_interval=300 + +first_collect=true +logsignal_normal= +logsignal_all=SIGUSR2 +signal_reload=SIGHUP + +# Thread recording +thread_record_enable=true +thread_record_buffer_size=100 # Set buffer size in MB. +thread_record_filename=heapstats_thread-records.htr +#thread_record_iotracer=/usr/local/etc/iotracer/IoTrace.class + +# Snmp setting +snmp_send=false +snmp_target=localhost +snmp_comname=public +# You can check library path with `net-snmp-config --netsnmp-libs` +snmp_libpath=/usr/lib64/libnetsnmp.so + +logdir=./tmp +archive_command=/usr/bin/zip %archivefile% -jr %logdir% + +kill_on_error=false
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorWaited/test.py Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,12 @@ +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +def Cond_OnClassPrepare(): + gdb.newest_frame().older().select() + symbol = gdb.execute("p (char *)klass->_name->_body", False, True) + return (symbol.find("DynLoad") != -1) + + +common.initialize("OnClassPrepare", Cond_OnClassPrepare, "OnMonitorWaited", common.return_true, True)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorWaited/testcase/Test.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,34 @@ +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; + + +public class Test implements Runnable{ + + public void run(){ + try{ + synchronized(Test.class){ + Test.class.wait(1000); + } + } + catch(IllegalArgumentException | + IllegalMonitorStateException | InterruptedException e){ + e.printStackTrace(); + } + } + + public static void main(String[] args) throws Exception{ + (new Thread(new Test())).start(); + + ClassLoader loader = new URLClassLoader(new URL[]{ + Paths.get(System.getProperty("java.class.path"), "dynload") + .toUri() + .toURL()}); + + Class<?> target = loader.loadClass("DynLoad"); + Method targetMethod = target.getMethod("call"); + Object targetObj = target.newInstance(); + targetMethod.invoke(targetObj); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MonitorWaited/testcase/dynload/DynLoad.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,5 @@ +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadEnd/buildenv.sh Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,10 @@ +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +unset JAVA_OPTS +export HEAPSTATS_CONF=heapstats-threadrecorder.conf + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/dynload/DynLoad.java +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadEnd/heapstats-threadrecorder.conf Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,70 @@ +# HeapStats 2.0.trunk +# HeapStats 2.0.trunk configuration file. +attach=true + +# Output file setting +file=heapstats_snapshot.dat +heaplogfile=heapstats_log.csv +archivefile=heapstats_analyze.zip +logfile= +loglevel=INFO +reduce_snapshot=true + +# SnapShot type +collect_reftree=true + +# Trigger snapshot setting +trigger_on_fullgc=true +trigger_on_dump=true + +# deadlock check +# This feature is experimental. It might be a cause of HotSpot internal error +# when you set this flag to true. +check_deadlock=false + +# Trigger logging setting +trigger_on_logerror=true +trigger_on_logsignal=true +trigger_on_loglock=true + +# Rank setting +rank_level=5 +rank_order=delta + +# Alert setting +alert_percentage=50 + +# Alert threshold for java heap usage. +# "0" means disabled. +javaheap_alert_percentage=95 + +# Alert threshold for metaspace usage (in MB). +# "0" means disabled. +metaspace_alert_threshold=0 + +# Timer setting +snapshot_interval=0 +log_interval=300 + +first_collect=true +logsignal_normal= +logsignal_all=SIGUSR2 +signal_reload=SIGHUP + +# Thread recording +thread_record_enable=true +thread_record_buffer_size=100 # Set buffer size in MB. +thread_record_filename=heapstats_thread-records.htr +#thread_record_iotracer=/usr/local/etc/iotracer/IoTrace.class + +# Snmp setting +snmp_send=false +snmp_target=localhost +snmp_comname=public +# You can check library path with `net-snmp-config --netsnmp-libs` +snmp_libpath=/usr/lib64/libnetsnmp.so + +logdir=./tmp +archive_command=/usr/bin/zip %archivefile% -jr %logdir% + +kill_on_error=false
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadEnd/test.py Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,12 @@ +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +def Cond_OnClassPrepare(): + gdb.newest_frame().older().select() + symbol = gdb.execute("p (char *)klass->_name->_body", False, True) + return (symbol.find("DynLoad") != -1) + + +common.initialize("OnClassPrepare", Cond_OnClassPrepare, "OnThreadEnd", common.return_true, True)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadEnd/testcase/Test.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,22 @@ +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; + + +public class Test{ + + public static void main(String[] args) throws Exception{ + (new Thread(() -> System.out.println("from new thread"))).start(); + + ClassLoader loader = new URLClassLoader(new URL[]{ + Paths.get(System.getProperty("java.class.path"), "dynload") + .toUri() + .toURL()}); + + Class<?> target = loader.loadClass("DynLoad"); + Method targetMethod = target.getMethod("call"); + Object targetObj = target.newInstance(); + targetMethod.invoke(targetObj); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadEnd/testcase/dynload/DynLoad.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,5 @@ +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadExhausted/buildenv.sh Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,12 @@ +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +unset JAVA_OPTS +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/dynload/DynLoad.java + +ulimit -Su 500 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadExhausted/test.py Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,12 @@ +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +def Cond_OnClassPrepare(): + gdb.newest_frame().older().select() + symbol = gdb.execute("p (char *)klass->_name->_body", False, True) + return (symbol.find("DynLoad") != -1) + + +common.initialize("OnClassPrepare", Cond_OnClassPrepare, "OnResourceExhausted", common.return_true, True)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadExhausted/testcase/Test.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,51 @@ +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; + + +public class Test{ + + public static void runClassLoad(){ + try{ + ClassLoader loader = new URLClassLoader(new URL[]{ + Paths.get(System.getProperty("java.class.path"), "dynload") + .toUri() + .toURL()}); + Class<?> target = loader.loadClass("DynLoad"); + Method targetMethod = target.getMethod("call"); + Object targetObj = target.newInstance(); + targetMethod.invoke(targetObj); + } + catch(Exception e){ + e.printStackTrace(); + } + } + + public static void runThreadleak(){ + Runnable waiter = () -> { + try{ + synchronized(Test.class){ + Test.class.wait(); + } + } + catch(InterruptedException e){ + e.printStackTrace(); + } + }; + + while(true){ + try{ + (new Thread(waiter)).start(); + } + catch(Throwable t){ + t.printStackTrace(); + System.exit(-1); + } + } + } + + public static void main(String[] args){ + (new Thread(Test::runClassLoad)).start(); + (new Thread(Test::runThreadleak)).start(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadExhausted/testcase/dynload/DynLoad.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,5 @@ +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadStart/buildenv.sh Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,10 @@ +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +unset JAVA_OPTS +export HEAPSTATS_CONF=heapstats-threadrecorder.conf + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/dynload/DynLoad.java +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadStart/heapstats-threadrecorder.conf Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,70 @@ +# HeapStats 2.0.trunk +# HeapStats 2.0.trunk configuration file. +attach=true + +# Output file setting +file=heapstats_snapshot.dat +heaplogfile=heapstats_log.csv +archivefile=heapstats_analyze.zip +logfile= +loglevel=INFO +reduce_snapshot=true + +# SnapShot type +collect_reftree=true + +# Trigger snapshot setting +trigger_on_fullgc=true +trigger_on_dump=true + +# deadlock check +# This feature is experimental. It might be a cause of HotSpot internal error +# when you set this flag to true. +check_deadlock=false + +# Trigger logging setting +trigger_on_logerror=true +trigger_on_logsignal=true +trigger_on_loglock=true + +# Rank setting +rank_level=5 +rank_order=delta + +# Alert setting +alert_percentage=50 + +# Alert threshold for java heap usage. +# "0" means disabled. +javaheap_alert_percentage=95 + +# Alert threshold for metaspace usage (in MB). +# "0" means disabled. +metaspace_alert_threshold=0 + +# Timer setting +snapshot_interval=0 +log_interval=300 + +first_collect=true +logsignal_normal= +logsignal_all=SIGUSR2 +signal_reload=SIGHUP + +# Thread recording +thread_record_enable=true +thread_record_buffer_size=100 # Set buffer size in MB. +thread_record_filename=heapstats_thread-records.htr +#thread_record_iotracer=/usr/local/etc/iotracer/IoTrace.class + +# Snmp setting +snmp_send=false +snmp_target=localhost +snmp_comname=public +# You can check library path with `net-snmp-config --netsnmp-libs` +snmp_libpath=/usr/lib64/libnetsnmp.so + +logdir=./tmp +archive_command=/usr/bin/zip %archivefile% -jr %logdir% + +kill_on_error=false
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadStart/test.py Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,12 @@ +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +def Cond_OnClassPrepare(): + gdb.newest_frame().older().select() + symbol = gdb.execute("p (char *)klass->_name->_body", False, True) + return (symbol.find("DynLoad") != -1) + + +common.initialize("OnClassPrepare", Cond_OnClassPrepare, "OnThreadStart", common.return_true, True)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadStart/testcase/Test.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,22 @@ +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; + + +public class Test{ + + public static void main(String[] args) throws Exception{ + (new Thread(() -> System.out.println("from new thread"))).start(); + + ClassLoader loader = new URLClassLoader(new URL[]{ + Paths.get(System.getProperty("java.class.path"), "dynload") + .toUri() + .toURL()}); + + Class<?> target = loader.loadClass("DynLoad"); + Method targetMethod = target.getMethod("call"); + Object targetObj = target.newInstance(); + targetMethod.invoke(targetObj); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadStart/testcase/dynload/DynLoad.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,5 @@ +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/VMDeath/buildenv.sh Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,10 @@ +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +unset JAVA_OPTS +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/dynload/DynLoad.java +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/VMDeath/test.py Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,12 @@ +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +def Cond_OnClassPrepare(): + gdb.newest_frame().older().select() + symbol = gdb.execute("p (char *)klass->_name->_body", False, True) + return (symbol.find("DynLoad") != -1) + + +common.initialize("OnClassPrepare", Cond_OnClassPrepare, "OnVMDeath", common.return_true, True)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/VMDeath/testcase/Test.java Tue Apr 11 18:05:01 2017 +0900 @@ -0,0 +1,30 @@ +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + public static void runClassLoad(){ + try{ + ClassLoader loader = new URLClassLoader(new URL[]{ + Paths.get(System.getProperty("java.class.path"), "dynload") + .toUri() + .toURL()}); + Class<?> target = loader.loadClass("DynLoad"); + Method targetMethod = target.getMethod("call"); + Object targetObj = target.newInstance(); + targetMethod.invoke(targetObj); + } + catch(Exception e){ + e.printStackTrace(); + } + } + + public static void main(String[] args){ + Thread th = new Thread(Test::runClassLoad); + th.setDaemon(true); + th.start(); + } +}