Tue, 31 Dec 2013 08:58:08 -0500
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
src/share/vm/services/attachListener.cpp | file | annotate | diff | comparison | revisions | |
src/share/vm/services/attachListener.hpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/services/attachListener.cpp Fri Aug 28 09:57:54 2015 +0200 1.2 +++ b/src/share/vm/services/attachListener.cpp Tue Dec 31 08:58:08 2013 -0500 1.3 @@ -466,15 +466,39 @@ 1.4 } 1.5 } 1.6 1.7 +bool AttachListener::has_init_error(TRAPS) { 1.8 + if (HAS_PENDING_EXCEPTION) { 1.9 + tty->print_cr("Exception in VM (AttachListener::init) : "); 1.10 + java_lang_Throwable::print(PENDING_EXCEPTION, tty); 1.11 + tty->cr(); 1.12 + 1.13 + CLEAR_PENDING_EXCEPTION; 1.14 + 1.15 + return true; 1.16 + } else { 1.17 + return false; 1.18 + } 1.19 +} 1.20 + 1.21 // Starts the Attach Listener thread 1.22 void AttachListener::init() { 1.23 EXCEPTION_MARK; 1.24 - Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK); 1.25 + Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, THREAD); 1.26 + if (has_init_error(THREAD)) { 1.27 + return; 1.28 + } 1.29 + 1.30 instanceKlassHandle klass (THREAD, k); 1.31 - instanceHandle thread_oop = klass->allocate_instance_handle(CHECK); 1.32 + instanceHandle thread_oop = klass->allocate_instance_handle(THREAD); 1.33 + if (has_init_error(THREAD)) { 1.34 + return; 1.35 + } 1.36 1.37 const char thread_name[] = "Attach Listener"; 1.38 - Handle string = java_lang_String::create_from_str(thread_name, CHECK); 1.39 + Handle string = java_lang_String::create_from_str(thread_name, THREAD); 1.40 + if (has_init_error(THREAD)) { 1.41 + return; 1.42 + } 1.43 1.44 // Initialize thread_oop to put it into the system threadGroup 1.45 Handle thread_group (THREAD, Universe::system_thread_group()); 1.46 @@ -487,13 +511,7 @@ 1.47 string, 1.48 THREAD); 1.49 1.50 - if (HAS_PENDING_EXCEPTION) { 1.51 - tty->print_cr("Exception in VM (AttachListener::init) : "); 1.52 - java_lang_Throwable::print(PENDING_EXCEPTION, tty); 1.53 - tty->cr(); 1.54 - 1.55 - CLEAR_PENDING_EXCEPTION; 1.56 - 1.57 + if (has_init_error(THREAD)) { 1.58 return; 1.59 } 1.60 1.61 @@ -505,14 +523,7 @@ 1.62 vmSymbols::thread_void_signature(), 1.63 thread_oop, // ARG 1 1.64 THREAD); 1.65 - 1.66 - if (HAS_PENDING_EXCEPTION) { 1.67 - tty->print_cr("Exception in VM (AttachListener::init) : "); 1.68 - java_lang_Throwable::print(PENDING_EXCEPTION, tty); 1.69 - tty->cr(); 1.70 - 1.71 - CLEAR_PENDING_EXCEPTION; 1.72 - 1.73 + if (has_init_error(THREAD)) { 1.74 return; 1.75 } 1.76
2.1 --- a/src/share/vm/services/attachListener.hpp Fri Aug 28 09:57:54 2015 +0200 2.2 +++ b/src/share/vm/services/attachListener.hpp Tue Dec 31 08:58:08 2013 -0500 2.3 @@ -94,6 +94,9 @@ 2.4 // dequeue the next operation 2.5 static AttachOperation* dequeue(); 2.6 #endif // !INCLUDE_SERVICES 2.7 + 2.8 + private: 2.9 + static bool has_init_error(TRAPS); 2.10 }; 2.11 2.12 #if INCLUDE_SERVICES