# HG changeset patch # User KUBOTA Yuji # Date 1498092919 -32400 # Node ID 84f67233da38eac8f5125d65907d9ac26baa6bf6 # Parent 4a05a154b09b2228513f5fbdee8701b85250803d Bug 3406: [TEST]Add race condition tests for core components Reviewed-by: yasuenag https://github.com/HeapStats/heapstats/pull/103 diff -r 4a05a154b09b -r 84f67233da38 ChangeLog --- a/ChangeLog Tue Jun 20 14:42:13 2017 +0900 +++ b/ChangeLog Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,7 @@ +2017-06-21 KUBOTA Yuji + + * Bug 3406: [TEST]Add race condition tests for core components + 2017-06-20 Yasumasa Suenaga * Bug 3405: HeapStats Agent cannot be built on CentOS 6 after Bug 3403 diff -r 4a05a154b09b -r 84f67233da38 agent/src/heapstats-engines/gcWatcher.cpp --- a/agent/src/heapstats-engines/gcWatcher.cpp Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/src/heapstats-engines/gcWatcher.cpp Thu Jun 22 09:55:19 2017 +0900 @@ -73,6 +73,7 @@ pthread_cond_wait(&controller->mutexCond, &controller->mutex); } +RACE_COND_DEBUG_POINT: /* If waiting finished by notification. */ if (likely(controller->_numRequests > 0)) { controller->_numRequests--; diff -r 4a05a154b09b -r 84f67233da38 agent/src/heapstats-engines/snapShotProcessor.cpp --- a/agent/src/heapstats-engines/snapShotProcessor.cpp Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/src/heapstats-engines/snapShotProcessor.cpp Thu Jun 22 09:55:19 2017 +0900 @@ -80,6 +80,7 @@ pthread_cond_wait(&controller->mutexCond, &controller->mutex); } +RACE_COND_DEBUG_POINT: /* If get notification means output. */ if (likely(controller->_numRequests > 0)) { controller->_numRequests--; diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ClassPrepare/buildenv.sh --- a/agent/test/race-condition/ClassPrepare/ClassPrepare/buildenv.sh Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ClassPrepare/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + #!/bin/sh export CLASSPATH=testcase diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ClassPrepare/test.py --- a/agent/test/race-condition/ClassPrepare/ClassPrepare/test.py Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ClassPrepare/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + import sys, os sys.path.append(os.pardir + "/../") diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ClassPrepare/testcase/Test.java --- a/agent/test/race-condition/ClassPrepare/ClassPrepare/testcase/Test.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ClassPrepare/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + import java.net.*; import java.nio.file.*; import java.lang.reflect.*; diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ClassPrepare/testcase/dynload/DynLoad.java --- a/agent/test/race-condition/ClassPrepare/ClassPrepare/testcase/dynload/DynLoad.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ClassPrepare/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + public class DynLoad{ public void call(){ System.out.println("from " + Thread.currentThread().getName()); diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ClassPrepare_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ClassPrepare_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../ClassPrepare/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ClassPrepare_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ClassPrepare_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ClassPrepare_safepoint/testcase --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ClassPrepare_safepoint/testcase Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../ClassPrepare/testcase \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/DataDumpRequest/buildenv.sh --- a/agent/test/race-condition/ClassPrepare/DataDumpRequest/buildenv.sh Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/DataDumpRequest/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + #!/bin/sh export CLASSPATH="$JAVA_HOME/lib/tools.jar:testcase" diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/DataDumpRequest/test.py --- a/agent/test/race-condition/ClassPrepare/DataDumpRequest/test.py Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/DataDumpRequest/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + import sys, os, time sys.path.append(os.pardir + "/../") diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/DataDumpRequest/testcase/Test.java --- a/agent/test/race-condition/ClassPrepare/DataDumpRequest/testcase/Test.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/DataDumpRequest/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + import java.util.stream.*; import java.net.*; import java.nio.file.*; diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/DataDumpRequest/testcase/dynload/DynLoad.java --- a/agent/test/race-condition/ClassPrepare/DataDumpRequest/testcase/dynload/DynLoad.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/DataDumpRequest/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + public class DynLoad{ public void call(){ System.out.println("from " + Thread.currentThread().getName()); diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/GCWatcher/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/GCWatcher/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,28 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/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 + diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/GCWatcher/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/GCWatcher/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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, "TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/GCWatcher/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/GCWatcher/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; + + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + + 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); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/GCWatcher/testcase/dynload/DynLoad.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/GCWatcher/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/GCWatcher_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/GCWatcher_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../GCWatcher/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/GCWatcher_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/GCWatcher_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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, "TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, True, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/GCWatcher_safepoint/testcase --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/GCWatcher_safepoint/testcase Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../GCWatcher/testcase \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MemoryExhausted/buildenv.sh --- a/agent/test/race-condition/ClassPrepare/MemoryExhausted/buildenv.sh Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MemoryExhausted/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + #!/bin/sh export CLASSPATH=testcase diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MemoryExhausted/test.py --- a/agent/test/race-condition/ClassPrepare/MemoryExhausted/test.py Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MemoryExhausted/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + import sys, os, time sys.path.append(os.pardir + "/../") diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MemoryExhausted/testcase/Test.java --- a/agent/test/race-condition/ClassPrepare/MemoryExhausted/testcase/Test.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MemoryExhausted/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + import java.net.*; import java.nio.file.*; import java.lang.reflect.*; diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MemoryExhausted/testcase/dynload/DynLoad.java --- a/agent/test/race-condition/ClassPrepare/MemoryExhausted/testcase/dynload/DynLoad.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MemoryExhausted/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + public class DynLoad{ public void call(){ System.out.println("from " + Thread.currentThread().getName()); diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MemoryExhausted_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MemoryExhausted_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../MemoryExhausted/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MemoryExhausted_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MemoryExhausted_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MemoryExhausted_safepoint/testcase --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/MemoryExhausted_safepoint/testcase Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../MemoryExhausted/testcase \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorContendedEnter/buildenv.sh --- a/agent/test/race-condition/ClassPrepare/MonitorContendedEnter/buildenv.sh Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEnter/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + #!/bin/sh export CLASSPATH=testcase diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorContendedEnter/test.py --- a/agent/test/race-condition/ClassPrepare/MonitorContendedEnter/test.py Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEnter/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + import sys, os, time sys.path.append(os.pardir + "/../") diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorContendedEnter/testcase/Test.java --- a/agent/test/race-condition/ClassPrepare/MonitorContendedEnter/testcase/Test.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEnter/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + import java.net.*; import java.nio.file.*; import java.lang.reflect.*; diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorContendedEnter/testcase/dynload/DynLoad.java --- a/agent/test/race-condition/ClassPrepare/MonitorContendedEnter/testcase/dynload/DynLoad.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEnter/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + public class DynLoad{ public void call(){ System.out.println("from " + Thread.currentThread().getName()); diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorContendedEntered/buildenv.sh --- a/agent/test/race-condition/ClassPrepare/MonitorContendedEntered/buildenv.sh Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEntered/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + #!/bin/sh export CLASSPATH=testcase diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorContendedEntered/test.py --- a/agent/test/race-condition/ClassPrepare/MonitorContendedEntered/test.py Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEntered/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + import sys, os, time sys.path.append(os.pardir + "/../") diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorContendedEntered/testcase/Test.java --- a/agent/test/race-condition/ClassPrepare/MonitorContendedEntered/testcase/Test.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEntered/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + import java.net.*; import java.nio.file.*; import java.lang.reflect.*; diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorContendedEntered/testcase/dynload/DynLoad.java --- a/agent/test/race-condition/ClassPrepare/MonitorContendedEntered/testcase/dynload/DynLoad.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorContendedEntered/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + public class DynLoad{ public void call(){ System.out.println("from " + Thread.currentThread().getName()); diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorWait/buildenv.sh --- a/agent/test/race-condition/ClassPrepare/MonitorWait/buildenv.sh Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorWait/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + #!/bin/sh export CLASSPATH=testcase diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorWait/test.py --- a/agent/test/race-condition/ClassPrepare/MonitorWait/test.py Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorWait/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + import sys, os, time sys.path.append(os.pardir + "/../") diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorWait/testcase/Test.java --- a/agent/test/race-condition/ClassPrepare/MonitorWait/testcase/Test.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorWait/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + import java.net.*; import java.nio.file.*; import java.lang.reflect.*; diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorWait/testcase/dynload/DynLoad.java --- a/agent/test/race-condition/ClassPrepare/MonitorWait/testcase/dynload/DynLoad.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorWait/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + public class DynLoad{ public void call(){ System.out.println("from " + Thread.currentThread().getName()); diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorWaited/buildenv.sh --- a/agent/test/race-condition/ClassPrepare/MonitorWaited/buildenv.sh Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorWaited/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + #!/bin/sh export CLASSPATH=testcase diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorWaited/test.py --- a/agent/test/race-condition/ClassPrepare/MonitorWaited/test.py Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorWaited/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + import sys, os, time sys.path.append(os.pardir + "/../") diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorWaited/testcase/Test.java --- a/agent/test/race-condition/ClassPrepare/MonitorWaited/testcase/Test.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorWaited/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + import java.net.*; import java.nio.file.*; import java.lang.reflect.*; diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/MonitorWaited/testcase/dynload/DynLoad.java --- a/agent/test/race-condition/ClassPrepare/MonitorWaited/testcase/dynload/DynLoad.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/MonitorWaited/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + public class DynLoad{ public void call(){ System.out.println("from " + Thread.currentThread().getName()); diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/SnapShotProcessor/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/SnapShotProcessor/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,28 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/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 + diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/SnapShotProcessor/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/SnapShotProcessor/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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, "TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/SnapShotProcessor/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/SnapShotProcessor/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; + + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + + 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); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/SnapShotProcessor/testcase/dynload/DynLoad.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/SnapShotProcessor/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/SnapShotProcessor_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/SnapShotProcessor_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../SnapShotProcessor/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/SnapShotProcessor_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/SnapShotProcessor_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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, "TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, True, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/SnapShotProcessor_safepoint/testcase --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/SnapShotProcessor_safepoint/testcase Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../SnapShotProcessor/testcase \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadEnd/buildenv.sh --- a/agent/test/race-condition/ClassPrepare/ThreadEnd/buildenv.sh Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ThreadEnd/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + #!/bin/sh export CLASSPATH=testcase diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadEnd/test.py --- a/agent/test/race-condition/ClassPrepare/ThreadEnd/test.py Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ThreadEnd/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + import sys, os, time sys.path.append(os.pardir + "/../") diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadEnd/testcase/Test.java --- a/agent/test/race-condition/ClassPrepare/ThreadEnd/testcase/Test.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ThreadEnd/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + import java.net.*; import java.nio.file.*; import java.lang.reflect.*; diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadEnd/testcase/dynload/DynLoad.java --- a/agent/test/race-condition/ClassPrepare/ThreadEnd/testcase/dynload/DynLoad.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ThreadEnd/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + public class DynLoad{ public void call(){ System.out.println("from " + Thread.currentThread().getName()); diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadExhausted/buildenv.sh --- a/agent/test/race-condition/ClassPrepare/ThreadExhausted/buildenv.sh Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ThreadExhausted/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + #!/bin/sh export CLASSPATH=testcase diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadExhausted/test.py --- a/agent/test/race-condition/ClassPrepare/ThreadExhausted/test.py Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ThreadExhausted/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + import sys, os, time sys.path.append(os.pardir + "/../") diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadExhausted/testcase/Test.java --- a/agent/test/race-condition/ClassPrepare/ThreadExhausted/testcase/Test.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ThreadExhausted/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + import java.net.*; import java.nio.file.*; import java.lang.reflect.*; diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadExhausted/testcase/dynload/DynLoad.java --- a/agent/test/race-condition/ClassPrepare/ThreadExhausted/testcase/dynload/DynLoad.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ThreadExhausted/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + public class DynLoad{ public void call(){ System.out.println("from " + Thread.currentThread().getName()); diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadExhausted_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadExhausted_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../ThreadExhausted/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadExhausted_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadExhausted_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadExhausted_safepoint/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadExhausted_safepoint/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; + + +public class Test{ + + public static void consumeMemory(){ + while(true){ + System.gc(); + try{ + Thread.sleep(1000); + } + catch(Exception e){ + e.printStackTrace(); + } + } + } + + 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(); + + /* Avoid PythonException not to create native thread for executing jcmd */ + Thread th = new Thread(Test::consumeMemory); + th.setDaemon(true); + th.start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadExhausted_safepoint/testcase/dynload/DynLoad.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ClassPrepare/ThreadExhausted_safepoint/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadStart/buildenv.sh --- a/agent/test/race-condition/ClassPrepare/ThreadStart/buildenv.sh Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ThreadStart/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + #!/bin/sh export CLASSPATH=testcase diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadStart/test.py --- a/agent/test/race-condition/ClassPrepare/ThreadStart/test.py Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ThreadStart/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + import sys, os, time sys.path.append(os.pardir + "/../") diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadStart/testcase/Test.java --- a/agent/test/race-condition/ClassPrepare/ThreadStart/testcase/Test.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ThreadStart/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + import java.net.*; import java.nio.file.*; import java.lang.reflect.*; diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/ThreadStart/testcase/dynload/DynLoad.java --- a/agent/test/race-condition/ClassPrepare/ThreadStart/testcase/dynload/DynLoad.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/ThreadStart/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + public class DynLoad{ public void call(){ System.out.println("from " + Thread.currentThread().getName()); diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/VMDeath/buildenv.sh --- a/agent/test/race-condition/ClassPrepare/VMDeath/buildenv.sh Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/VMDeath/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + #!/bin/sh export CLASSPATH=testcase diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/VMDeath/test.py --- a/agent/test/race-condition/ClassPrepare/VMDeath/test.py Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/VMDeath/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + import sys, os, time sys.path.append(os.pardir + "/../") diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/VMDeath/testcase/Test.java --- a/agent/test/race-condition/ClassPrepare/VMDeath/testcase/Test.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/VMDeath/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + import java.net.*; import java.nio.file.*; import java.lang.reflect.*; diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ClassPrepare/VMDeath/testcase/dynload/DynLoad.java --- a/agent/test/race-condition/ClassPrepare/VMDeath/testcase/dynload/DynLoad.java Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/ClassPrepare/VMDeath/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + public class DynLoad{ public void call(){ System.out.println("from " + Thread.currentThread().getName()); diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/CMSRemark/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/CMSRemark/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,26 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/CMSRemark/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/CMSRemark/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "VM_CMS_Final_Remark::doit", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/CMSRemark/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/CMSRemark/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + Thread.sleep(3000); // Sleep 3 secs to wait breakpoint... + System.gc(); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/G1Cleanup/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/G1Cleanup/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,26 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/G1Cleanup/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/G1Cleanup/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "callbackForG1Cleanup", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/G1Cleanup/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/G1Cleanup/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + Thread.sleep(3000); // Sleep 3 secs to wait breakpoint... + System.gc(); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/MemoryExhausted/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/MemoryExhausted/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,26 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-Xmx500m" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/MemoryExhausted/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/MemoryExhausted/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("OnResourceExhausted", common.return_true, "TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/MemoryExhausted/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/MemoryExhausted/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.util.*; + + +public class Test{ + + public static void runMemleak(){ + List list = new ArrayList<>(); + + while(true){ + list.add(new byte[1024*1024]); + } + } + + public static void runGC(){ + try{ + while(true){ + System.gc(); + Thread.sleep(100); + } + } + catch(Exception e){ + e.printStackTrace(); + } + } + + public static void main(String[] args){ + Thread gcThread = new Thread(Test::runGC); + gcThread.setDaemon(true); + gcThread.start(); + (new Thread(Test::runMemleak)).start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/MemoryExhausted_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/MemoryExhausted_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../MemoryExhausted/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/MemoryExhausted_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/MemoryExhausted_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time, threading +sys.path.append(os.pardir + "/../") + +import common + +# Kick GC after occurring GC. +def Kick_GC(): + threading.Thread(target=os.system, args=("jcmd 0 GC.run",)).start() + return True + + +common.initialize("OnResourceExhausted", Kick_GC, "TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/MemoryExhausted_safepoint/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/MemoryExhausted_safepoint/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.util.*; + + +public class Test{ + + public static void runMemleak(){ + List list = new ArrayList<>(); + + while(true){ + list.add(new byte[1024*1024]); + } + } + + public static void main(String[] args){ + (new Thread(Test::runMemleak)).start(); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/OnClassPrepare/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/OnClassPrepare/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,28 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/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 + diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/OnClassPrepare/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/OnClassPrepare/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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("TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "OnClassPrepare", Cond_OnClassPrepare, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/OnClassPrepare/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/OnClassPrepare/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; + + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + + 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); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/OnClassPrepare/testcase/dynload/DynLoad.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/OnClassPrepare/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/OnClassPrepare_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/OnClassPrepare_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../OnClassPrepare/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/OnClassPrepare_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/OnClassPrepare_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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("TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "OnClassPrepare", Cond_OnClassPrepare, True, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/OnClassPrepare_safepoint/testcase --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/OnClassPrepare_safepoint/testcase Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../OnClassPrepare/testcase/ \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ParNewGCStart/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ParNewGCStart/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,26 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-Xmn10m -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ParNewGCStart/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ParNewGCStart/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "VM_GenCollectForAllocation::doit", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ParNewGCStart/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ParNewGCStart/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.util.*; + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + Thread.sleep(3000); // Sleep 3 secs to wait breakpoint... + System.gc(); + + List list = new ArrayList<>(); + for(int i = 1; i < 10; i++){ + list.add(new byte[1024 * 1024]); // 1MB + } + + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ParallelGarbageCollectionStart/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ParallelGarbageCollectionStart/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,26 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-XX:+UseParallelGC -XX:-UseParallelOldGC" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ParallelGarbageCollectionStart/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ParallelGarbageCollectionStart/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "OnGarbageCollectionStart", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ParallelGarbageCollectionStart/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ParallelGarbageCollectionStart/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + Thread.sleep(3000); // Sleep 3 secs to wait breakpoint... + System.gc(); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ParallelOldGarbageCollectionStart/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ParallelOldGarbageCollectionStart/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,26 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-XX:-UseParallelOldGC" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ParallelOldGarbageCollectionStart/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ParallelOldGarbageCollectionStart/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "OnGarbageCollectionStart", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ParallelOldGarbageCollectionStart/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ParallelOldGarbageCollectionStart/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + Thread.sleep(3000); // Sleep 3 secs to wait breakpoint... + System.gc(); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/SnapShotProcessor/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/SnapShotProcessor/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,26 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +unset JAVA_OPTS +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/SnapShotProcessor/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/SnapShotProcessor/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/SnapShotProcessor/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/SnapShotProcessor/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + System.gc(); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/SnapShotProcessor_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/SnapShotProcessor_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../SnapShotProcessor/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/SnapShotProcessor_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/SnapShotProcessor_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False, True, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/SnapShotProcessor_safepoint/testcase --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/SnapShotProcessor_safepoint/testcase Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../SnapShotProcessor/testcase \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ThreadExhausted/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ThreadExhausted/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,28 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +unset JAVA_OPTS +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java + +ulimit -Su 500 diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ThreadExhausted/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ThreadExhausted/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "OnResourceExhausted", common.return_true, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ThreadExhausted/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ThreadExhausted/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + 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::runThreadleak)).start(); + System.gc(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ThreadExhausted_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ThreadExhausted_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../ThreadExhausted/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ThreadExhausted_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ThreadExhausted_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("OnResourceExhausted", common.return_true, "TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, True, True, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/GCWatcher/ThreadExhausted_safepoint/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/GCWatcher/ThreadExhausted_safepoint/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + 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 runGC(){ + while(true){ + System.gc(); + try{ + Thread.sleep(10000); + } + catch(Exception e){ + e.printStackTrace(); + } + } + } + + public static void main(String[] args){ + (new Thread(Test::runThreadleak)).start(); + (new Thread(Test::runGC)).start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/ClassPrepare/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/ClassPrepare/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,46 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/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 + diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/ClassPrepare/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/ClassPrepare/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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("OnResourceExhausted", common.return_true, "OnClassPrepare", Cond_OnClassPrepare, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/ClassPrepare/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/ClassPrepare/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +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 list = new ArrayList<>(); + + while(true){ + list.add(new byte[1024*1024]); + } + } + + public static void main(String[] args){ + (new Thread(Test::runClassLoad)).start(); + (new Thread(Test::runMemleak)).start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/ClassPrepare/testcase/dynload/DynLoad.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/ClassPrepare/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/ClassPrepare_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/ClassPrepare_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../ClassPrepare/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/ClassPrepare_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/ClassPrepare_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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("OnResourceExhausted", common.return_true, "OnClassPrepare", Cond_OnClassPrepare, True, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/ClassPrepare_safepoint/testcase --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/ClassPrepare_safepoint/testcase Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../ClassPrepare/testcase/ \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/GCWatcher/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/GCWatcher/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,44 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-Xmx500m" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/GCWatcher/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/GCWatcher/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("OnResourceExhausted", common.return_true, "TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/GCWatcher/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/GCWatcher/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + public static void runMemleak(){ + List list = new ArrayList<>(); + + while(true){ + list.add(new byte[1024*1024]); + } + } + + public static void runGC(){ + while(true){ + try{ + System.gc(); + Thread.sleep(100); + } + catch(Throwable t){ + t.printStackTrace(); + System.exit(-1); + } + } + } + + public static void main(String[] args){ + Thread memleakThread = new Thread(Test::runMemleak); + Thread gcThread = new Thread(Test::runGC); + gcThread.setDaemon(true); + + gcThread.start(); + memleakThread.start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/GCWatcher_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/GCWatcher_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../GCWatcher/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/GCWatcher_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/GCWatcher_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,29 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time, threading +sys.path.append(os.pardir + "/../") + +import common + +# Kick GC after occurring GC. +def Kick_GC(): + threading.Thread(target=os.system, args=("jcmd 0 GC.run",)).start() + return True + +common.initialize("OnResourceExhausted", Kick_GC, "TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/GCWatcher_safepoint/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/GCWatcher_safepoint/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + public static void runMemleak(){ + List list = new ArrayList<>(); + + while(true){ + list.add(new byte[1024*1024]); + } + } + + public static void main(String[] args){ + (new Thread(Test::runMemleak)).start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/MemoryExhausted/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/MemoryExhausted/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,44 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-Xmx500m" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/MemoryExhausted/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/MemoryExhausted/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("OnResourceExhausted", common.return_true, "OnResourceExhausted", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/MemoryExhausted/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/MemoryExhausted/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + public static void runMemleak(){ + List 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::runMemleak)).start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/MemoryExhausted_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/MemoryExhausted_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../MemoryExhausted/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/MemoryExhausted_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/MemoryExhausted_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("OnResourceExhausted", common.return_true, "OnResourceExhausted", common.return_true, False, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/MemoryExhausted_safepoint/testcase --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/MemoryExhausted_safepoint/testcase Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../MemoryExhausted/testcase \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/SnapShotProcessor/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/SnapShotProcessor/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,44 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-Xmx500m" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/SnapShotProcessor/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/SnapShotProcessor/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("OnResourceExhausted", common.return_true, "TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/SnapShotProcessor/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/SnapShotProcessor/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + public static void runMemleak(){ + List list = new ArrayList<>(); + + while(true){ + list.add(new byte[1024*1024]); + } + } + + public static void runGC(){ + while(true){ + try{ + System.gc(); + Thread.sleep(100); + } + catch(Throwable t){ + t.printStackTrace(); + System.exit(-1); + } + } + } + + public static void main(String[] args){ + Thread memleakThread = new Thread(Test::runMemleak); + Thread gcThread = new Thread(Test::runGC); + gcThread.setDaemon(true); + + gcThread.start(); + memleakThread.start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/SnapShotProcessor_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/SnapShotProcessor_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../SnapShotProcessor/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/SnapShotProcessor_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/SnapShotProcessor_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("OnResourceExhausted", common.return_true, "TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/SnapShotProcessor_safepoint/testcase --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/SnapShotProcessor_safepoint/testcase Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../SnapShotProcessor/testcase \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/ThreadExhausted/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/ThreadExhausted/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,46 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-Xmx500m" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java + +ulimit -Su 500 diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/ThreadExhausted/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/ThreadExhausted/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,39 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common +import re + +# from jvmti.h +JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP = 0x0002 +JVMTI_RESOURCE_EXHAUSTED_THREADS = 0x0004 + +def flagToInt(): + m = re.search("\d+$", gdb.execute("p flags", False, True)) + return int(m.group(0)) + +def Cond_MemoryExhausted(): + return ((flagToInt() & JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP) != 0) + +def Cond_ThreadExhausted(): + return ((flagToInt() & JVMTI_RESOURCE_EXHAUSTED_THREADS) != 0) + +common.initialize("OnResourceExhausted", Cond_MemoryExhausted, "OnResourceExhausted", Cond_ThreadExhausted, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/ThreadExhausted/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/ThreadExhausted/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + public static void runMemleak(){ + List list = new ArrayList<>(); + + while(true){ + list.add(new byte[1024*1024]); + } + } + + 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::runMemleak)).start(); + (new Thread(Test::runThreadleak)).start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/ThreadExhausted_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/ThreadExhausted_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../ThreadExhausted/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/ThreadExhausted_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/ThreadExhausted_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,39 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common +import re + +# from jvmti.h +JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP = 0x0002 +JVMTI_RESOURCE_EXHAUSTED_THREADS = 0x0004 + +def flagToInt(): + m = re.search("\d+$", gdb.execute("p flags", False, True)) + return int(m.group(0)) + +def Cond_MemoryExhausted(): + return ((flagToInt() & JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP) != 0) + +def Cond_ThreadExhausted(): + return ((flagToInt() & JVMTI_RESOURCE_EXHAUSTED_THREADS) != 0) + +common.initialize("OnResourceExhausted", Cond_MemoryExhausted, "OnResourceExhausted", Cond_ThreadExhausted, True, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/MemoryExhausted/ThreadExhausted_safepoint/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/MemoryExhausted/ThreadExhausted_safepoint/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + public static void runMemleak(){ + List list = new ArrayList<>(); + + while(true){ + list.add(new byte[1024*1024]); + } + } + + 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 runGC(){ + while(true){ + System.gc(); + try{ + Thread.sleep(1000); + } + catch(Exception e){ + e.printStackTrace(); + } + } + } + + public static void main(String[] args){ + (new Thread(Test::runGC)).start(); + (new Thread(Test::runMemleak)).start(); + (new Thread(Test::runThreadleak)).start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/CMSRemark/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/CMSRemark/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,44 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/CMSRemark/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/CMSRemark/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "VM_CMS_Final_Remark::doit", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/CMSRemark/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/CMSRemark/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + Thread.sleep(3000); // Sleep 3 secs to wait breakpoint... + System.gc(); + Thread.sleep(10000); // Sleep 10 secs again to avoid missing... + System.gc(); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/G1Cleanup/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/G1Cleanup/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,44 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/G1Cleanup/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/G1Cleanup/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "callbackForG1Cleanup", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/G1Cleanup/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/G1Cleanup/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + Thread.sleep(3000); // Sleep 3 secs to wait breakpoint... + System.gc(); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/GCWatcher/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/GCWatcher/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,44 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +unset JAVA_OPTS +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/GCWatcher/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/GCWatcher/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/GCWatcher/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/GCWatcher/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + System.gc(); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/GCWatcher_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/GCWatcher_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../GCWatcher/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/GCWatcher_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/GCWatcher_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/GCWatcher_safepoint/testcase --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/GCWatcher_safepoint/testcase Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../GCWatcher/testcase \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/MemoryExhausted/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/MemoryExhausted/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,44 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-Xmx500m" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/MemoryExhausted/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/MemoryExhausted/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "OnResourceExhausted", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/MemoryExhausted/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/MemoryExhausted/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.util.*; + + +public class Test{ + + public static void runMemleak(){ + List list = new ArrayList<>(); + + while(true){ + list.add(new byte[1024*1024]); + } + } + + public static void main(String[] args){ + (new Thread(Test::runMemleak)).start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/MemoryExhausted_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/MemoryExhausted_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../MemoryExhausted/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/MemoryExhausted_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/MemoryExhausted_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "OnResourceExhausted", common.return_true, False, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/MemoryExhausted_safepoint/testcase --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/MemoryExhausted_safepoint/testcase Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../MemoryExhausted/testcase/ \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/OnClassPrepare/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/OnClassPrepare/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,46 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/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 + diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/OnClassPrepare/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/OnClassPrepare/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "OnClassPrepare", Cond_OnClassPrepare, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/OnClassPrepare/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/OnClassPrepare/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; + + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + + 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); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/OnClassPrepare/testcase/dynload/DynLoad.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/OnClassPrepare/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/OnClassPrepare_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/OnClassPrepare_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../OnClassPrepare/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/OnClassPrepare_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/OnClassPrepare_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "OnClassPrepare", Cond_OnClassPrepare, True, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/OnClassPrepare_safepoint/testcase --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/OnClassPrepare_safepoint/testcase Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../OnClassPrepare/testcase \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ParNewGCStart/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ParNewGCStart/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,44 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-Xmn10m -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ParNewGCStart/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ParNewGCStart/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "VM_GenCollectForAllocation::doit", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ParNewGCStart/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ParNewGCStart/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.util.*; + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + Thread.sleep(3000); // Sleep 3 secs to wait breakpoint... + System.gc(); + + List list = new ArrayList<>(); + for(int i = 1; i < 10; i++){ + list.add(new byte[1024 * 1024]); // 1MB + } + + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ParallelGarbageCollectionStart/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ParallelGarbageCollectionStart/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,44 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-XX:+UseParallelGC -XX:-UseParallelOldGC" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ParallelGarbageCollectionStart/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ParallelGarbageCollectionStart/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "OnGarbageCollectionStart", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ParallelGarbageCollectionStart/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ParallelGarbageCollectionStart/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + Thread.sleep(3000); // Sleep 3 secs to wait breakpoint... + System.gc(); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ParallelOldGarbageCollectionStart/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ParallelOldGarbageCollectionStart/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,44 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-XX:-UseParallelOldGC" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ParallelOldGarbageCollectionStart/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ParallelOldGarbageCollectionStart/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "OnGarbageCollectionStart", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ParallelOldGarbageCollectionStart/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ParallelOldGarbageCollectionStart/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + public static void main(String[] args) throws Exception{ + System.gc(); + Thread.sleep(3000); // Sleep 3 secs to wait breakpoint... + System.gc(); + } + +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ThreadExhausted/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ThreadExhausted/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,46 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +unset JAVA_OPTS +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java + +ulimit -Su 500 diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ThreadExhausted/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ThreadExhausted/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "OnResourceExhausted", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ThreadExhausted/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ThreadExhausted/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + 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::runThreadleak)).start(); + System.gc(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ThreadExhausted_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ThreadExhausted_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../ThreadExhausted/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ThreadExhausted_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ThreadExhausted_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, "OnResourceExhausted", common.return_true, False, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/SnapShotProcessor/ThreadExhausted_safepoint/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/SnapShotProcessor/ThreadExhausted_safepoint/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + 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 runGC(){ + while(true){ + System.gc(); + try{ + Thread.sleep(10000); + } + catch(Exception e){ + e.printStackTrace(); + } + } + } + + public static void main(String[] args){ + (new Thread(Test::runThreadleak)).start(); + (new Thread(Test::runGC)).start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/GCWatcher/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/GCWatcher/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,46 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-Xmx500m" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java + +ulimit -Su 500 diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/GCWatcher/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/GCWatcher/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("OnResourceExhausted", common.return_true, "TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/GCWatcher/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/GCWatcher/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + 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 runGC(){ + while(true){ + try{ + System.gc(); + Thread.sleep(100); + } + catch(Throwable t){ + t.printStackTrace(); + System.exit(-1); + } + } + } + + public static void main(String[] args){ + Thread threadleakThread = new Thread(Test::runThreadleak); + Thread gcThread = new Thread(Test::runGC); + gcThread.setDaemon(true); + + gcThread.start(); + threadleakThread.start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/GCWatcher_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/GCWatcher_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../GCWatcher/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/GCWatcher_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/GCWatcher_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,25 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + + +common.initialize("OnResourceExhausted", common.return_true, "TGCWatcher::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/GCWatcher_safepoint/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/GCWatcher_safepoint/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class Test{ + + 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 runGC(){ + while(true){ + System.gc(); + try{ + Thread.sleep(10000); + } + catch(Exception e){ + e.printStackTrace(); + } + } + } + + public static void main(String[] args){ + (new Thread(Test::runThreadleak)).start(); + (new Thread(Test::runGC)).start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/MemoryExhausted/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/MemoryExhausted/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,46 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-Xmx500m" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java + +ulimit -Su 500 diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/MemoryExhausted/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/MemoryExhausted/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,39 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common +import re + +# from jvmti.h +JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP = 0x0002 +JVMTI_RESOURCE_EXHAUSTED_THREADS = 0x0004 + +def flagToInt(): + m = re.search("\d+$", gdb.execute("p flags", False, True)) + return int(m.group(0)) + +def Cond_MemoryExhausted(): + return ((flagToInt() & JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP) != 0) + +def Cond_ThreadExhausted(): + return ((flagToInt() & JVMTI_RESOURCE_EXHAUSTED_THREADS) != 0) + +common.initialize("OnResourceExhausted", Cond_ThreadExhausted, "OnResourceExhausted", Cond_MemoryExhausted, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/MemoryExhausted/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/MemoryExhausted/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + public static void runMemleak(){ + List list = new ArrayList<>(); + + while(true){ + list.add(new byte[1024*1024]); + } + } + + 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::runMemleak)).start(); + (new Thread(Test::runThreadleak)).start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/MemoryExhausted_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/MemoryExhausted_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../MemoryExhausted/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/MemoryExhausted_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/MemoryExhausted_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,39 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common +import re + +# from jvmti.h +JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP = 0x0002 +JVMTI_RESOURCE_EXHAUSTED_THREADS = 0x0004 + +def flagToInt(): + m = re.search("\d+$", gdb.execute("p flags", False, True)) + return int(m.group(0)) + +def Cond_MemoryExhausted(): + return ((flagToInt() & JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP) != 0) + +def Cond_ThreadExhausted(): + return ((flagToInt() & JVMTI_RESOURCE_EXHAUSTED_THREADS) != 0) + +common.initialize("OnResourceExhausted", Cond_ThreadExhausted, "OnResourceExhausted", Cond_MemoryExhausted, True, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/MemoryExhausted_safepoint/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/MemoryExhausted_safepoint/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + public static void runMemleak(){ + List list = new ArrayList<>(); + + while(true){ + list.add(new byte[1024*1024]); + } + } + + 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 runGC(){ + while(true){ + System.gc(); + try{ + Thread.sleep(1000); + } + catch(Exception e){ + e.printStackTrace(); + } + } + } + + public static void main(String[] args){ + (new Thread(Test::runMemleak)).start(); + (new Thread(Test::runThreadleak)).start(); + + Thread gcThread = new Thread(Test::runGC); + gcThread.setDaemon(true); + gcThread.start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/OnClassPrepare/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/OnClassPrepare/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,48 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/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 + diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/OnClassPrepare/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/OnClassPrepare/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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("OnResourceExhausted", common.return_true, "OnClassPrepare", Cond_OnClassPrepare, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/OnClassPrepare/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/OnClassPrepare/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +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(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/OnClassPrepare/testcase/dynload/DynLoad.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/OnClassPrepare/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/OnClassPrepare_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/OnClassPrepare_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../OnClassPrepare/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/OnClassPrepare_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/OnClassPrepare_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,30 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +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("OnResourceExhausted", common.return_true, "OnClassPrepare", Cond_OnClassPrepare, True, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/OnClassPrepare_safepoint/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/OnClassPrepare_safepoint/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +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 runGC(){ + while(true){ + System.gc(); + try{ + Thread.sleep(1000); + } + catch(Exception e){ + e.printStackTrace(); + } + } + } + + public static void main(String[] args){ + (new Thread(Test::runClassLoad)).start(); + (new Thread(Test::runThreadleak)).start(); + + Thread gcThread = new Thread(Test::runGC); + gcThread.setDaemon(true); + gcThread.start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/OnClassPrepare_safepoint/testcase/dynload/DynLoad.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/OnClassPrepare_safepoint/testcase/dynload/DynLoad.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +public class DynLoad{ + public void call(){ + System.out.println("from " + Thread.currentThread().getName()); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/SnapShotProcessor/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/SnapShotProcessor/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,46 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-Xmx500m" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java + +ulimit -Su 500 diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/SnapShotProcessor/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/SnapShotProcessor/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("OnResourceExhausted", common.return_true, "TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/SnapShotProcessor/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/SnapShotProcessor/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + 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 runGC(){ + while(true){ + try{ + System.gc(); + Thread.sleep(100); + } + catch(Throwable t){ + t.printStackTrace(); + System.exit(-1); + } + } + } + + public static void main(String[] args){ + Thread threadleakThread = new Thread(Test::runThreadleak); + Thread gcThread = new Thread(Test::runGC); + gcThread.setDaemon(true); + + gcThread.start(); + threadleakThread.start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/SnapShotProcessor_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/SnapShotProcessor_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../SnapShotProcessor/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/SnapShotProcessor_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/SnapShotProcessor_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("OnResourceExhausted", common.return_true, "TSnapShotProcessor::entryPoint:RACE_COND_DEBUG_POINT", common.return_true, False, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/SnapShotProcessor_safepoint/testcase --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/SnapShotProcessor_safepoint/testcase Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../SnapShotProcessor/testcase \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/ThreadExhausted/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/ThreadExhausted/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,46 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +#!/bin/sh + +export CLASSPATH=testcase +export MAINCLASS=Test +export JAVA_OPTS="-Xmx500m" +unset HEAPSTATS_CONF + +$JAVA_HOME/bin/javac $TEST_TARGET/testcase/Test.java + +ulimit -Su 500 diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/ThreadExhausted/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/ThreadExhausted/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("OnResourceExhausted", common.return_true, "OnResourceExhausted", common.return_true, False) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/ThreadExhausted/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/ThreadExhausted/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + 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::runThreadleak)).start(); + (new Thread(Test::runThreadleak)).start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/ThreadExhausted_safepoint/buildenv.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/ThreadExhausted_safepoint/buildenv.sh Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,1 @@ +../ThreadExhausted/buildenv.sh \ No newline at end of file diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/ThreadExhausted_safepoint/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/ThreadExhausted_safepoint/test.py Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,24 @@ +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import sys, os, time +sys.path.append(os.pardir + "/../") + +import common + +common.initialize("OnResourceExhausted", common.return_true, "OnResourceExhausted", common.return_true, False, False, True) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/ThreadExhausted/ThreadExhausted_safepoint/testcase/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/test/race-condition/ThreadExhausted/ThreadExhausted_safepoint/testcase/Test.java Thu Jun 22 09:55:19 2017 +0900 @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* + * Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.net.*; +import java.nio.file.*; +import java.lang.reflect.*; +import java.util.*; + + +public class Test{ + + 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 runGC(){ + while(true){ + System.gc(); + try{ + Thread.sleep(1000); + } + catch(Exception e){ + e.printStackTrace(); + } + } + } + + public static void main(String[] args){ + (new Thread(Test::runThreadleak)).start(); + (new Thread(Test::runThreadleak)).start(); + + Thread gcThread = new Thread(Test::runGC); + gcThread.setDaemon(true); + gcThread.start(); + } +} diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/common.py --- a/agent/test/race-condition/common.py Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/common.py Thu Jun 22 09:55:19 2017 +0900 @@ -1,4 +1,22 @@ -import gdb +''' +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' + +import gdb, threading, os class ContinueInvoker: def __init__(self, th): @@ -25,31 +43,78 @@ return False +class SafepointBreaker(gdb.Breakpoint): + def __init__(self, rcgen): + super(SafepointBreaker, self).__init__("Interpreter::notice_safepoints") + self.at_safepoint = False + self.__rcgen = rcgen + + def stop(self): + self.at_safepoint = True + self.enabled = False + self.__rcgen.coordinate() + return False + + class RaceConditionGenerator: - def __init__(self, primary, secondary, secondary_enabled): + def __init__(self, primary, secondary, secondary_enabled, need_safepoint, is_reverse): self.__primary = primary self.__secondary = secondary self.__secondary_enabled = secondary_enabled + self.__need_safepoint = need_safepoint + self.__safepoint_breaker = None + self.__is_reverse = is_reverse def coordinate(self): if((not self.__secondary_enabled) and (not self.__primary.enabled) and (self.__secondary.thread_num == -1)): self.__secondary.enabled = True elif((self.__primary.thread_num != -1) and (self.__secondary.thread_num != -1)): + if self.__need_safepoint: + if self.__safepoint_breaker is None: + self.__safepoint_breaker = SafepointBreaker(self) + threading.Thread(target=os.system, args=("jcmd 0 GC.run",)).start() + return + elif not self.__safepoint_breaker.at_safepoint: + return + gdb.write("Test start!\n") - gdb.post_event(ContinueInvoker(self.__primary.thread_num)) - gdb.post_event(ContinueInvoker(self.__secondary.thread_num)) + gdb.execute("p SafepointSynchronize::_state") + if self.__is_reverse: + gdb.post_event(ContinueInvoker(self.__secondary.thread_num)) + gdb.post_event(ContinueInvoker(self.__primary.thread_num)) + else: + gdb.post_event(ContinueInvoker(self.__primary.thread_num)) + gdb.post_event(ContinueInvoker(self.__secondary.thread_num)) + + +def is_stopped(): + result = True + for thread in gdb.selected_inferior().threads(): + result &= thread.is_stopped() + return result class StopHandler: def __init__(self, rcgen): self.__rcgen = rcgen + self.__is_abort = False def __call__(self, event): # Ignore signals - if(isinstance(event, gdb.SignalEvent)): - gdb.post_event(ContinueInvoker(event.inferior_thread.num)) - elif(isinstance(event, gdb.BreakpointEvent)): + if isinstance(event, gdb.SignalEvent): + if(event.stop_signal == "SIGABRT"): + self.__is_abort = True + gdb.write("Stop all threads...\n") + gdb.execute("interrupt -a") + else: + gdb.post_event(ContinueInvoker(event.inferior_thread.num)) + elif isinstance(event, gdb.BreakpointEvent): self.__rcgen.coordinate() + elif(self.__is_abort and is_stopped()): + self.__is_abort = False + gdb.write("Dumping core...\n") + gdb.execute("gcore") + gdb.execute("quit") def return_true(): @@ -60,7 +125,8 @@ gdb.execute("quit") -def initialize(primary, primary_cond, secondary, secondary_cond, secondary_enabled): +def initialize(primary, primary_cond, secondary, secondary_cond, secondary_enabled, is_reverse=False, at_safepoint=False): + gdb.execute("set confirm off") gdb.execute("set breakpoint pending on") gdb.execute("set target-async on") gdb.execute("set pagination off") @@ -69,7 +135,7 @@ p = BreakPointHandler(primary, primary_cond) s = BreakPointHandler(secondary, secondary_cond) s.enabled = secondary_enabled - rcgen = RaceConditionGenerator(p, s, secondary_enabled) + rcgen = RaceConditionGenerator(p, s, secondary_enabled, at_safepoint, is_reverse) gdb.events.stop.connect(StopHandler(rcgen)) gdb.events.exited.connect(exit_handler) diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/testcase.sh --- a/agent/test/race-condition/testcase.sh Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/testcase.sh Thu Jun 22 09:55:19 2017 +0900 @@ -1,9 +1,45 @@ +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + +<< LICENSE +Copyright (C) 2017 Nippon Telegraph and Telephone Corporation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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 for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +LICENSE + #!/bin/sh pushd $(dirname $0) >/dev/null if [[ $1 == "--clean" ]]; then - find . \( -name "*.class" -o -name "core*" -o -name "hs_err*log" -o -name "*.gdb" -o -name "*.log" -o -name command.gdb -o -name "heapstats_*" -o -name "test-failed" -o -name "test-succeeded" \) -exec rm -f {} \; + find . \( -name "*.class" -o -name "core*" -o -name "hs_err*log" -o -name "*.gdb" -o -name "*.log" -o -name command.gdb -o -name "heapstats_*" -o -name "test-failed" -o -name "test-succeeded" -o -name "tmp*" -o -name core \) -exec rm -fR {} \; rm -fR __pycache__ exit fi diff -r 4a05a154b09b -r 84f67233da38 agent/test/race-condition/testlist.txt --- a/agent/test/race-condition/testlist.txt Tue Jun 20 14:42:13 2017 +0900 +++ b/agent/test/race-condition/testlist.txt Thu Jun 22 09:55:19 2017 +0900 @@ -1,1 +1,5 @@ ClassPrepare/* +MemoryExhausted/* +ThreadExhausted/* +SnapShotProcessor/* +GCWatcher/*