changeset 34:54cf38a69dca

Bug 2017: JVM may crash with taking interval SnapShot when concurrent GC is occurred. reviewed-by: ykubota
author Yasumasa Suenaga <yasuenag@gmail.com>
date Fri, 17 Oct 2014 22:32:57 +0900
parents 539df4f40392
children 4502530ca7bd
files agent/ChangeLog agent/src/oopUtil.cpp agent/src/oopUtil.hpp agent/src/snapShotMain.cpp
diffstat 4 files changed, 35 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/agent/ChangeLog	Fri Aug 22 10:27:43 2014 +0900
+++ b/agent/ChangeLog	Fri Oct 17 22:32:57 2014 +0900
@@ -1,3 +1,7 @@
+2014-10-17 Yasumasa Suenaga  <yasuenag@gmail.com>
+
+	* Bug 2017: JVM may crash with taking interval SnapShot when concurrent GC is occurred.
+
 2014-08-22  KUBOTA Yuji  <kubota.yuji@lab.ntt.co.jp>
 
 	* Bump to 1.1.2
--- a/agent/src/oopUtil.cpp	Fri Aug 22 10:27:43 2014 +0900
+++ b/agent/src/oopUtil.cpp	Fri Oct 17 22:32:57 2014 +0900
@@ -2924,21 +2924,30 @@
             throw 1;
         }
 
-        /*
-         * See 7046558: G1: concurrent marking optimizations.
-         * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7046558
-         * http://hg.openjdk.java.net/hsx/hotspot-gc/hotspot/rev/842b840e67db
-         */
         if(useG1){
+            /*
+             * See 7046558: G1: concurrent marking optimizations.
+             * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7046558
+             * http://hg.openjdk.java.net/hsx/hotspot-gc/hotspot/rev/842b840e67db
+             */
             const unsigned int afterCR7046558 = 22 << 24 | 3;
-            
             if (unlikely(hotSpotVersion < afterCR7046558)) {
-                
                 /* Heapstats agent is unsupported G1GC on JDK6. */
                 PRINT_CRIT_MSG("Sorry, G1GC isn't supported in this version.");
                 PRINT_CRIT_MSG("You should use >= 22.0-b03");
                 throw 1;
             }
+
+            if(arg.TimerInterval > 0){
+              PRINT_WARN_MSG("Interval SnapShot is not supported with G1GC. Turn off.");
+              arg.TimerInterval = 0;
+            }
+
+            if(arg.triggerOnDump){
+              PRINT_WARN_MSG("SnapShot trigger on dump request is not supported with G1GC. Turn off.");
+              arg.triggerOnDump = false;
+            }
+
         }
         
         /* Search common function symbol in libjvm. */
--- a/agent/src/oopUtil.hpp	Fri Aug 22 10:27:43 2014 +0900
+++ b/agent/src/oopUtil.hpp	Fri Oct 17 22:32:57 2014 +0900
@@ -218,6 +218,15 @@
 extern "C" bool useG1;
 
 /*!
+ * \brief CMS collector state pointer.
+ * \sa concurrentMarkSweepGeneration.hpp<br>
+ *     at hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/<br>
+ *     enum CollectorState
+ */
+extern int *CMS_collectorState;
+
+
+/*!
  * \brief JVM safepoint state pointer.
  */
 extern "C" int *safePointState;
--- a/agent/src/snapShotMain.cpp	Fri Aug 22 10:27:43 2014 +0900
+++ b/agent/src/snapShotMain.cpp	Fri Oct 17 22:32:57 2014 +0900
@@ -660,6 +660,12 @@
  *                   e.g. GC, DumpRequest or Interval.
  */
 void TakeSnapShot(jvmtiEnv *jvmti, JNIEnv *env, TInvokeCause cause) {
+
+    if(useCMS && (*CMS_collectorState > CMS_IDLING)){
+      PRINT_WARN_MSG("CMS GC is working. Skip to take a SnapShot.");
+      return;
+    }
+
     /* Count working time. */
     static const char *label = "Take SnapShot";
     TElapsedTimer elapsedTime(label);