hotspot/src/share/vm/runtime/deoptimization.cpp
changeset 22241 58579a498f3a
parent 20282 7f9cbdf89af2
child 22872 b6902ee5bc8d
child 22551 9bf46d16dcc6
--- 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");
   }
 }