6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error

Fixed incompatible uses of EXCEPTION_MARK and CHECK macros in AttachListener::init(), handle exception locally.

Reviewed-by: minqi, coleenp
This commit is contained in:
Zhengyu Gu 2013-12-31 08:58:08 -05:00
parent ac9faf4243
commit e0ca30c97b
2 changed files with 32 additions and 18 deletions

View File

@ -451,15 +451,39 @@ static void attach_listener_thread_entry(JavaThread* thread, TRAPS) {
}
}
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 @@ void AttachListener::init() {
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 @@ void AttachListener::init() {
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;
}

View File

@ -94,6 +94,9 @@ class AttachListener: AllStatic {
// dequeue the next operation
static AttachOperation* dequeue();
#endif // !INCLUDE_SERVICES
private:
static bool has_init_error(TRAPS);
};
#if INCLUDE_SERVICES