changeset 58:d1ee335f73a0

Bug 2452: JVM may crash when CMS GC occurs frequently. reviewed-by: ShinTak
author Yasumasa Suenaga <yasuenag@gmail.com>
date Fri, 19 Jun 2015 22:09:33 +0900
parents fd76f06f8e57
children 32e54f07df8d
files agent/ChangeLog agent/src/snapShotMain.cpp
diffstat 2 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/agent/ChangeLog	Thu May 28 17:19:06 2015 +0900
+++ b/agent/ChangeLog	Fri Jun 19 22:09:33 2015 +0900
@@ -1,3 +1,7 @@
+2015-06-19 Yasumasa Suenaga  <yasuenag@gmail.com>
+
+	* Bug 2452: JVM may crash when CMS GC occurs frequently.
+
 2015-05-28 KUBOTA Yuji  <kubota.yuji@lab.ntt.co.jp>
 
 	* Bump to 1.0.4
--- a/agent/src/snapShotMain.cpp	Thu May 28 17:19:06 2015 +0900
+++ b/agent/src/snapShotMain.cpp	Fri Jun 19 22:09:33 2015 +0900
@@ -450,8 +450,23 @@
  */
 void TakeSnapShot(jvmtiEnv *jvmti, JNIEnv *env, TInvokeCause cause) {
 
-  if(useCMS && (*CMS_collectorState > CMS_IDLING)){
+  /*
+   * Initial Mark is 1st phase in CMS.
+   * So we can process the SnapShot in SnapShot queue.
+   */
+  if(useCMS && (*CMS_collectorState > CMS_INITIALMARKING)){
     PRINT_WARN_MSG("CMS GC is working. Skip to take a SnapShot.");
+    TSnapShotContainer *snapshot = NULL;
+
+    ENTER_PTHREAD_SECTION(&queueMutex) {
+      snapshot = snapStockQueue.front();
+      snapStockQueue.pop();
+    } EXIT_PTHREAD_SECTION(&queueMutex)
+
+    if(likely(snapshot != NULL)){
+      TSnapShotContainer::releaseInstance(snapshot);
+    }
+
     return;
   }