# HG changeset patch # User zgu # Date 1388498288 18000 # Node ID 41ea552a447d62d4ccd8c1462c8f85b0cdd4db51 # Parent b48393754f75d5b7a1760658e5605f7adfe6437e 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 diff -r b48393754f75 -r 41ea552a447d hotspot/src/share/vm/services/attachListener.cpp --- 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; } diff -r b48393754f75 -r 41ea552a447d hotspot/src/share/vm/services/attachListener.hpp --- 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