United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6448241 exception oop left in TLS during exception lookup causing assertions if class loading occurs
JDK-6448241 : exception oop left in TLS during exception lookup causing assertions if class loading occurs

Details
Type:
Bug
Submit Date:
2006-07-12
Status:
Resolved
Updated Date:
2012-12-18
Project Name:
JDK
Resolved Date:
2006-11-14
Component:
hotspot
OS:
solaris_9
Sub-Component:
compiler
CPU:
sparc
Priority:
P4
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
hs10 (b03)

Related Reports
Backport:
Backport:

Sub Tasks

Description
/net/vmsqe/export/nightly/mantis/DTWS/results/07-10-06/ClientVM/solx86/comp/C2_Baseline/nsk.stress-11-NIGHTLY-C2_Baseline-ClientVM-comp-solx86-2006-07-11-00-11-59/hs_err_pid28531.log ./

foundation% /net/jano/export/disk05/hotspot/bin/hs_err --jvm=./libjvm.so hs_err_pid28531.log
#=============== DEBUG MESSAGE: exception oop must be empty ================
#
#
# An unexpected error has been detected by Java Runtime Environment:
#
#  Internal Error (/net/prt-solx86-q1-5/PrtBuildDir/workspace/src/cpu/i486/vm/assembler_i486.cpp, 3343), pid=28531, tid=214
#
# Java VM: Java HotSpot(TM) Client VM (20060710121006.kvn.main_to_c2_baseline-debug compiled mode, sharing)
#
# Error: assert(false,"DEBUG MESSAGE")
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

---------------  T H R E A D  ---------------

Current thread (0x081a5800):  JavaThread "Thread-204" [_thread_in_vm, id=214]

Stack: [0xca9ca000,0xcaa1a000),  sp=0xcaa178f8,  free space=310k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x914997];;  __1cHVMErrorOreport_and_die6M_v_+0x517
V  [libjvm.so+0x2991d7];;  __1cYreport_assertion_failure6Fpkci1_v_+0x5f
V  [libjvm.so+0x8ce26];;  __1cOMacroAssemblerFdebug6Fiiiiiiiiipc_v_+0x356
v  ~RuntimeStub::unwind_exception Runtime1 stub
J  sun.reflect.misc.MethodUtil.loadClass(Ljava/lang/String;Z)Ljava/lang/Class;
J  java.lang.ClassLoader.loadClass(Ljava/lang/String;)Ljava/lang/Class;
J  java.lang.ClassLoader.loadClassInternal(Ljava/lang/String;)Ljava/lang/Class;
v  ~StubRoutines::call_stub
V  [libjvm.so+0x3798f5];;  __1cJJavaCallsLcall_helper6FpnJJavaValue_pnMmethodHandle_pnRJavaCallArguments_pnGThread__v_+0x69d
V  [libjvm.so+0x72ef1b];;  __1cCosUos_exception_wrapper6FpFpnJJavaValue_pnMmethodHandle_pnRJavaCallArguments_pnGThread__v2468_v_+0x27
V  [libjvm.so+0x37922c];;  __1cJJavaCallsEcall6FpnJJavaValue_nMmethodHandle_pnRJavaCallArguments_pnGThread__v_+0x40
V  [libjvm.so+0x378ab7];;  __1cJJavaCallsMcall_special6FpnJJavaValue_nLKlassHandle_nMsymbolHandle_4pnRJavaCallArguments_pnGThread__v_+0x6f
V  [libjvm.so+0x378cf6];;  __1cJJavaCallsMcall_special6FpnJJavaValue_nGHandle_nLKlassHandle_nMsymbolHandle_53pnGThread__v_+0x12e
V  [libjvm.so+0x8135a5];;  __1cQSystemDictionaryTload_instance_class6FnMsymbolHandle_nGHandle_pnGThread__nTinstanceKlassHandle__+0x391
V  [libjvm.so+0x80e6e5];;  __1cQSystemDictionarybEresolve_instance_class_or_null6FnMsymbolHandle_nGHandle_2pnGThread__nIklassOop__+0x15c1
V  [libjvm.so+0x80a631];;  __1cQSystemDictionaryPresolve_or_null6FnMsymbolHandle_nGHandle_2pnGThread__nIklassOop__+0x189
V  [libjvm.so+0x809b82];;  __1cQSystemDictionaryPresolve_or_fail6FnMsymbolHandle_nGHandle_2bpnGThread__nIklassOop__+0x2e
V  [libjvm.so+0x28731a];;  __1cTconstantPoolOopDescNklass_at_impl6FnSconstantPoolHandle_ipnGThread__nIklassOop__+0x942
V  [libjvm.so+0x166d35];;  __1cTconstantPoolOopDescIklass_at6MipnGThread__nIklassOop__+0x18d
V  [libjvm.so+0x6e0d63];;  __1cNmethodOopDescbEfast_exception_handler_bci_for6MnLKlassHandle_ipnGThread__i_+0x7f3
V  [libjvm.so+0x7b2a03];;  __1cNSharedRuntimebCcompute_compiled_exc_handler6FpnHnmethod_pCrnGHandle_bb_3_+0x32b
V  [libjvm.so+0x15d938];;  __1cbFexception_handler_for_pc_helper6FpnKJavaThread_pnHoopDesc_pCrpnHnmethod__4_+0xf3c
V  [libjvm.so+0x15daf6];;  __1cIRuntime1Yexception_handler_for_pc6FpnKJavaThread__pC_+0x72
v  ~RuntimeStub::handle_exception_nofpu Runtime1 stub
J  sun.reflect.GeneratedMethodAccessor292.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
J  sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
J  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
J  sun.reflect.misc.MethodUtil.invoke(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
.
Here's a test case for this:

/*
 * @test %W% %E%
 * @bug 6448241
 * @run main/othervm -Xcomp -Xverify:none eoop
 */

public class eoop {
    static class UnloadedThrowable extends RuntimeException {
        static boolean throwIt = true;
        static {
            if (throwIt)
                throw new InternalError("can't load this");
        }
    }

    public static void main(String[] args) {
        try {
            throw new InternalError("throw me");
        } catch (UnloadedThrowable e) {
        }
    }
}

                                    

Comments
SUGGESTED FIX

*** /tmp/geta17725      Wed Jul 12 14:35:42 2006
--- c1_Runtime1.cpp     Wed Jul 12 14:31:30 2006
***************
*** 438,446 ****
--- 438,453 ----
      // for AbortVMOnException flag
      NOT_PRODUCT(Exceptions::debug_check_abort(exception));

+     // Clear out the exception oop since looking up an exception
+     // handler can cause class loading and execution of bytecodes
+     // which might get unhappy if the exception is still in TLS.
+     thread->set_exception_oop(NULL);
+     thread->set_exception_pc(NULL);
+
      continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false);
      // If an exception was thrown during exception dispatch, the exception oop may have changed
      thread->set_exception_oop(exception());
+     thread->set_exception_pc(pc);

      // the exception cache is used only by non-implicit exceptions
      if (continuation == NULL) {
                                     
2006-07-12
EVALUATION

When calling out to do the lookup we should clear out the exception_oop and exception_pc.  We already restore exception_oop on return and we probably should restore exception_pc though we're probably done with it at that point.
                                     
2006-07-12



Hardware and Software, Engineered to Work Together