# HG changeset patch # User Yasumasa Suenaga # Date 1413552547 -32400 # Node ID f2220f6e86b7449de94a73baa2e7a8ef6f32cb3a # Parent 496fc55ddc329d04954ee0952b73da3f3c56cdbf Bug 2017: JVM may crash with taking interval SnapShot when concurrent GC is occurred. reviewed-by: ykubota diff -r 496fc55ddc32 -r f2220f6e86b7 agent/ChangeLog --- a/agent/ChangeLog Fri Aug 22 10:18:27 2014 +0900 +++ b/agent/ChangeLog Fri Oct 17 22:29:07 2014 +0900 @@ -1,3 +1,7 @@ +2014-10-17 KUBOTA Yuji + + * Bug 2017: JVM may crash with taking interval SnapShot when concurrent GC is occurred. + 2014-08-22 KUBOTA Yuji * Bump to 1.0.3 diff -r 496fc55ddc32 -r f2220f6e86b7 agent/src/oopUtil.cpp --- a/agent/src/oopUtil.cpp Fri Aug 22 10:18:27 2014 +0900 +++ b/agent/src/oopUtil.cpp Fri Oct 17 22:29:07 2014 +0900 @@ -2349,12 +2349,24 @@ } if(useG1){ + if(unlikely(!jvmInfo->isAfterCR7046558())){ /* Heapstats agent is unsupported G1GC on JDK6. */ PRINT_CRIT_MSG("Sorry, G1GC isn't supported in this HotSpot version."); PRINT_CRIT_MSG("You should use >= 22.0-b03"); return false; } + + 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; + } + } return true; diff -r 496fc55ddc32 -r f2220f6e86b7 agent/src/oopUtil.hpp --- a/agent/src/oopUtil.hpp Fri Aug 22 10:18:27 2014 +0900 +++ b/agent/src/oopUtil.hpp Fri Oct 17 22:29:07 2014 +0900 @@ -190,6 +190,15 @@ extern "C" bool useG1; /*! + * \brief CMS collector state pointer. + * \sa concurrentMarkSweepGeneration.hpp
+ * at hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/
+ * enum CollectorState + */ +extern int *CMS_collectorState; + + +/*! * \brief JVM safepoint state pointer. */ extern "C" int *safePointState; diff -r 496fc55ddc32 -r f2220f6e86b7 agent/src/snapShotMain.cpp --- a/agent/src/snapShotMain.cpp Fri Aug 22 10:18:27 2014 +0900 +++ b/agent/src/snapShotMain.cpp Fri Oct 17 22:29:07 2014 +0900 @@ -449,6 +449,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);