diff -r ec02eda6b9b6 -r 58579a498f3a hotspot/src/share/vm/runtime/deoptimization.cpp --- a/hotspot/src/share/vm/runtime/deoptimization.cpp Tue Jan 07 14:26:12 2014 -0800 +++ b/hotspot/src/share/vm/runtime/deoptimization.cpp Wed Jan 08 09:49:31 2014 +0100 @@ -1224,9 +1224,19 @@ load_class_by_index(constant_pool, index, THREAD); if (HAS_PENDING_EXCEPTION) { // Exception happened during classloading. We ignore the exception here, since it - // is going to be rethrown since the current activation is going to be deoptimzied and + // is going to be rethrown since the current activation is going to be deoptimized and // the interpreter will re-execute the bytecode. CLEAR_PENDING_EXCEPTION; + // Class loading called java code which may have caused a stack + // overflow. If the exception was thrown right before the return + // to the runtime the stack is no longer guarded. Reguard the + // stack otherwise if we return to the uncommon trap blob and the + // stack bang causes a stack overflow we crash. + assert(THREAD->is_Java_thread(), "only a java thread can be here"); + JavaThread* thread = (JavaThread*)THREAD; + bool guard_pages_enabled = thread->stack_yellow_zone_enabled(); + if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack(); + assert(guard_pages_enabled, "stack banging in uncommon trap blob may cause crash"); } }