src/share/vm/prims/jvmtiEnvBase.cpp

changeset 4673
5ee250974db9
parent 4492
8b46b0196eb0
child 6876
710a3c8b516e
child 6911
ce8f6bb717c9
     1.1 --- a/src/share/vm/prims/jvmtiEnvBase.cpp	Wed Feb 27 16:40:30 2013 +0000
     1.2 +++ b/src/share/vm/prims/jvmtiEnvBase.cpp	Wed Feb 27 15:00:30 2013 -0800
     1.3 @@ -997,13 +997,19 @@
     1.4        // move our object at this point. However, our owner value is safe
     1.5        // since it is either the Lock word on a stack or a JavaThread *.
     1.6        owning_thread = Threads::owning_thread_from_monitor_owner(owner, !at_safepoint);
     1.7 -      assert(owning_thread != NULL, "sanity check");
     1.8 -      if (owning_thread != NULL) {  // robustness
     1.9 +      // Cannot assume (owning_thread != NULL) here because this function
    1.10 +      // may not have been called at a safepoint and the owning_thread
    1.11 +      // might not be suspended.
    1.12 +      if (owning_thread != NULL) {
    1.13          // The monitor's owner either has to be the current thread, at safepoint
    1.14          // or it has to be suspended. Any of these conditions will prevent both
    1.15          // contending and waiting threads from modifying the state of
    1.16          // the monitor.
    1.17          if (!at_safepoint && !JvmtiEnv::is_thread_fully_suspended(owning_thread, true, &debug_bits)) {
    1.18 +          // Don't worry! This return of JVMTI_ERROR_THREAD_NOT_SUSPENDED
    1.19 +          // will not make it back to the JVM/TI agent. The error code will
    1.20 +          // get intercepted in JvmtiEnv::GetObjectMonitorUsage() which
    1.21 +          // will retry the call via a VM_GetObjectMonitorUsage VM op.
    1.22            return JVMTI_ERROR_THREAD_NOT_SUSPENDED;
    1.23          }
    1.24          HandleMark hm;

mercurial