You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2006/12/22 23:22:31 UTC

svn commit: r489785 - in /harmony/enhanced/drlvm/trunk/vm/vmcore: include/jvmti_direct.h src/exception/exceptions_jit.cpp src/jvmti/jvmti_event.cpp

Author: gshimansky
Date: Fri Dec 22 14:22:31 2006
New Revision: 489785

URL: http://svn.apache.org/viewvc?view=rev&rev=489785
Log:
Applied HARMONY-2833 [drlvm][jvmti] NULL pointer access inside GetObjectClass() for exception object

Tests passed on Ubuntu6 x86, WindowsXP x86 and SuSE9 x86_64


Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h?view=diff&rev=489785&r1=489784&r2=489785
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h Fri Dec 22 14:22:31 2006
@@ -144,6 +144,7 @@
 VMEXPORT void jvmti_interpreter_exception_event_callback_call(
         ManagedObject *exc, Method *method, jlocation location,
         Method *catch_method, jlocation catch_location);
+bool jvmti_is_exception_event_requested();
 ManagedObject *jvmti_jit_exception_event_callback_call(ManagedObject *exn,
     JIT *jit, Method *method, NativeCodePtr native_location,
     JIT *catch_jit, Method *catch_method, NativeCodePtr native_catch_location);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp?view=diff&rev=489785&r1=489784&r2=489785
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp Fri Dec 22 14:22:31 2006
@@ -303,14 +303,22 @@
                         jit_exn_constr_args, vm_exn_constr_args);
                 }
 
-                BEGIN_RAISE_AREA;
-                // Reload exception object pointer because it could have
-                // moved while calling JVMTI callback
-                *exn_obj = jvmti_jit_exception_event_callback_call(*exn_obj,
-                    interrupted_method_jit, interrupted_method,
-                    interrupted_method_location,
-                    jit, method, handler->get_handler_ip());
-                END_RAISE_AREA;
+                if (jvmti_is_exception_event_requested()) {
+                    // Create exception if necessary
+                    if (NULL == *exn_obj) {
+                        *exn_obj = create_lazy_exception(exn_class, exn_constr,
+                            jit_exn_constr_args, vm_exn_constr_args);
+                    }
+
+                    BEGIN_RAISE_AREA;
+                    // Reload exception object pointer because it could have
+                    // moved while calling JVMTI callback
+                    *exn_obj = jvmti_jit_exception_event_callback_call(*exn_obj,
+                        interrupted_method_jit, interrupted_method,
+                        interrupted_method_location,
+                        jit, method, handler->get_handler_ip());
+                    END_RAISE_AREA;
+                }
 
                 TRACE2("exn", ("setting return pointer to %d", exn_obj));
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp?view=diff&rev=489785&r1=489784&r2=489785
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp Fri Dec 22 14:22:31 2006
@@ -1322,11 +1322,27 @@
     assert(!exn_raised());
 }
 
+bool jvmti_is_exception_event_requested()
+{
+    DebugUtilsTI *ti = VM_Global_State::loader_env->TI;
+    if (!ti->isEnabled())
+        return false;
+
+    if (JVMTI_PHASE_LIVE != ti->getPhase())
+        return false;
+
+    if (!ti->get_global_capability(DebugUtilsTI::TI_GC_ENABLE_EXCEPTION_EVENT))
+        return false;
+
+    return true;
+}
+
 ManagedObject *jvmti_jit_exception_event_callback_call(ManagedObject *exn_object,
     JIT *jit, Method *method, NativeCodePtr native_location,
     JIT *catch_jit, Method *catch_method, NativeCodePtr native_catch_location)
 {
     assert(!exn_raised());
+    assert(exn_object);
     SuspendDisabledChecker sdc;
 
     DebugUtilsTI *ti = VM_Global_State::loader_env->TI;