6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
authorzgu
Tue, 31 Dec 2013 08:58:08 -0500
changeset 22197 41ea552a447d
parent 22196 b48393754f75
child 22198 ab9e76f5a36c
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error Summary: Fixed incompatible uses of EXCEPTION_MARK and CHECK macros in AttachListener::init(), handle exception locally. Reviewed-by: minqi, coleenp
hotspot/src/share/vm/services/attachListener.cpp
hotspot/src/share/vm/services/attachListener.hpp
--- a/hotspot/src/share/vm/services/attachListener.cpp	Mon Dec 23 18:44:59 2013 -0500
+++ b/hotspot/src/share/vm/services/attachListener.cpp	Tue Dec 31 08:58:08 2013 -0500
@@ -451,15 +451,39 @@
   }
 }
 
+bool AttachListener::has_init_error(TRAPS) {
+  if (HAS_PENDING_EXCEPTION) {
+    tty->print_cr("Exception in VM (AttachListener::init) : ");
+    java_lang_Throwable::print(PENDING_EXCEPTION, tty);
+    tty->cr();
+
+    CLEAR_PENDING_EXCEPTION;
+
+    return true;
+  } else {
+    return false;
+  }
+}
+
 // Starts the Attach Listener thread
 void AttachListener::init() {
   EXCEPTION_MARK;
-  Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
+  Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, THREAD);
+  if (has_init_error(THREAD)) {
+    return;
+  }
+
   instanceKlassHandle klass (THREAD, k);
-  instanceHandle thread_oop = klass->allocate_instance_handle(CHECK);
+  instanceHandle thread_oop = klass->allocate_instance_handle(THREAD);
+  if (has_init_error(THREAD)) {
+    return;
+  }
 
   const char thread_name[] = "Attach Listener";
-  Handle string = java_lang_String::create_from_str(thread_name, CHECK);
+  Handle string = java_lang_String::create_from_str(thread_name, THREAD);
+  if (has_init_error(THREAD)) {
+    return;
+  }
 
   // Initialize thread_oop to put it into the system threadGroup
   Handle thread_group (THREAD, Universe::system_thread_group());
@@ -472,13 +496,7 @@
                        string,
                        THREAD);
 
-  if (HAS_PENDING_EXCEPTION) {
-    tty->print_cr("Exception in VM (AttachListener::init) : ");
-    java_lang_Throwable::print(PENDING_EXCEPTION, tty);
-    tty->cr();
-
-    CLEAR_PENDING_EXCEPTION;
-
+  if (has_init_error(THREAD)) {
     return;
   }
 
@@ -490,14 +508,7 @@
                         vmSymbols::thread_void_signature(),
                         thread_oop,             // ARG 1
                         THREAD);
-
-  if (HAS_PENDING_EXCEPTION) {
-    tty->print_cr("Exception in VM (AttachListener::init) : ");
-    java_lang_Throwable::print(PENDING_EXCEPTION, tty);
-    tty->cr();
-
-    CLEAR_PENDING_EXCEPTION;
-
+  if (has_init_error(THREAD)) {
     return;
   }
 
--- a/hotspot/src/share/vm/services/attachListener.hpp	Mon Dec 23 18:44:59 2013 -0500
+++ b/hotspot/src/share/vm/services/attachListener.hpp	Tue Dec 31 08:58:08 2013 -0500
@@ -94,6 +94,9 @@
   // dequeue the next operation
   static AttachOperation* dequeue();
 #endif // !INCLUDE_SERVICES
+
+ private:
+  static bool has_init_error(TRAPS);
 };
 
 #if INCLUDE_SERVICES