src/share/vm/services/threadService.cpp

changeset 5271
ef748153ee8f
parent 4673
5ee250974db9
child 6122
0b9ea9a72436
     1.1 --- a/src/share/vm/services/threadService.cpp	Mon Jun 10 10:45:19 2013 -0400
     1.2 +++ b/src/share/vm/services/threadService.cpp	Mon Jun 17 18:35:44 2013 +0200
     1.3 @@ -327,27 +327,30 @@
     1.4      while (waitingToLockMonitor != NULL || waitingToLockBlocker != NULL) {
     1.5        cycle->add_thread(currentThread);
     1.6        if (waitingToLockMonitor != NULL) {
     1.7 -        currentThread = Threads::owning_thread_from_monitor_owner(
     1.8 -                          (address)waitingToLockMonitor->owner(),
     1.9 -                          false /* no locking needed */);
    1.10 -        if (currentThread == NULL) {
    1.11 -          // This function is called at a safepoint so the JavaThread
    1.12 -          // that owns waitingToLockMonitor should be findable, but
    1.13 -          // if it is not findable, then the previous currentThread is
    1.14 -          // blocked permanently. We record this as a deadlock.
    1.15 -          num_deadlocks++;
    1.16 +        address currentOwner = (address)waitingToLockMonitor->owner();
    1.17 +        if (currentOwner != NULL) {
    1.18 +          currentThread = Threads::owning_thread_from_monitor_owner(
    1.19 +                            currentOwner,
    1.20 +                            false /* no locking needed */);
    1.21 +          if (currentThread == NULL) {
    1.22 +            // This function is called at a safepoint so the JavaThread
    1.23 +            // that owns waitingToLockMonitor should be findable, but
    1.24 +            // if it is not findable, then the previous currentThread is
    1.25 +            // blocked permanently. We record this as a deadlock.
    1.26 +            num_deadlocks++;
    1.27  
    1.28 -          cycle->set_deadlock(true);
    1.29 +            cycle->set_deadlock(true);
    1.30  
    1.31 -          // add this cycle to the deadlocks list
    1.32 -          if (deadlocks == NULL) {
    1.33 -            deadlocks = cycle;
    1.34 -          } else {
    1.35 -            last->set_next(cycle);
    1.36 +            // add this cycle to the deadlocks list
    1.37 +            if (deadlocks == NULL) {
    1.38 +              deadlocks = cycle;
    1.39 +            } else {
    1.40 +              last->set_next(cycle);
    1.41 +            }
    1.42 +            last = cycle;
    1.43 +            cycle = new DeadlockCycle();
    1.44 +            break;
    1.45            }
    1.46 -          last = cycle;
    1.47 -          cycle = new DeadlockCycle();
    1.48 -          break;
    1.49          }
    1.50        } else {
    1.51          if (concurrent_locks) {

mercurial