< prev index next >

src/hotspot/share/services/threadService.cpp

Print this page

 418     // It isn't clear how to make deadlock detection work correctly if that
 419     // happens.
 420     waitingToLockRawMonitor = jt->current_pending_raw_monitor();
 421 
 422     if (concurrent_locks) {
 423       waitingToLockBlocker = jt->current_park_blocker();
 424     }
 425 
 426     while (waitingToLockMonitor != NULL ||
 427            waitingToLockRawMonitor != NULL ||
 428            waitingToLockBlocker != NULL) {
 429       cycle->add_thread(currentThread);
 430       // Give preference to the raw monitor
 431       if (waitingToLockRawMonitor != NULL) {
 432         Thread* owner = waitingToLockRawMonitor->owner();
 433         if (owner != NULL && // the raw monitor could be released at any time
 434             owner->is_Java_thread()) {
 435           currentThread = owner->as_Java_thread();
 436         }
 437       } else if (waitingToLockMonitor != NULL) {
 438         address currentOwner = (address)waitingToLockMonitor->owner();
 439         if (currentOwner != NULL) {
 440           currentThread = Threads::owning_thread_from_monitor_owner(t_list,
 441                                                                     currentOwner);
 442           if (currentThread == NULL) {
 443             // This function is called at a safepoint so the JavaThread
 444             // that owns waitingToLockMonitor should be findable, but
 445             // if it is not findable, then the previous currentThread is
 446             // blocked permanently. We record this as a deadlock.
 447             num_deadlocks++;
 448 
 449             cycle->set_deadlock(true);
 450 
 451             // add this cycle to the deadlocks list
 452             if (deadlocks == NULL) {
 453               deadlocks = cycle;
 454             } else {
 455               last->set_next(cycle);
 456             }
 457             last = cycle;
 458             cycle = new DeadlockCycle();
 459             break;
 460           }
 461         }

 997         if (owner->is_Java_thread()) {
 998           currentThread = owner->as_Java_thread();
 999           st->print_cr("%s \"%s\"", owner_desc, currentThread->get_thread_name());
1000         } else {
1001           st->print_cr(",\n  which has now been released");
1002         }
1003       } else {
1004         st->print_cr("%s non-Java thread=" PTR_FORMAT, owner_desc, p2i(owner));
1005       }
1006     }
1007 
1008     if (waitingToLockMonitor != NULL) {
1009       st->print("  waiting to lock monitor " INTPTR_FORMAT, p2i(waitingToLockMonitor));
1010       oop obj = waitingToLockMonitor->object();
1011       st->print(" (object " INTPTR_FORMAT ", a %s)", p2i(obj),
1012                  obj->klass()->external_name());
1013 
1014       if (!currentThread->current_pending_monitor_is_from_java()) {
1015         owner_desc = "\n  in JNI, which is held by";
1016       }
1017       currentThread = Threads::owning_thread_from_monitor_owner(t_list,
1018                                                                 (address)waitingToLockMonitor->owner());
1019       if (currentThread == NULL) {
1020         // The deadlock was detected at a safepoint so the JavaThread
1021         // that owns waitingToLockMonitor should be findable, but
1022         // if it is not findable, then the previous currentThread is
1023         // blocked permanently.
1024         st->print_cr("%s UNKNOWN_owner_addr=" PTR_FORMAT, owner_desc,
1025                   p2i(waitingToLockMonitor->owner()));
1026         continue;
1027       }
1028     } else {
1029       st->print("  waiting for ownable synchronizer " INTPTR_FORMAT ", (a %s)",
1030                 p2i(waitingToLockBlocker),
1031                 waitingToLockBlocker->klass()->external_name());
1032       assert(waitingToLockBlocker->is_a(vmClasses::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass()),
1033              "Must be an AbstractOwnableSynchronizer");
1034       oop ownerObj = java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(waitingToLockBlocker);
1035       currentThread = java_lang_Thread::thread(ownerObj);
1036       assert(currentThread != NULL, "AbstractOwnableSynchronizer owning thread is unexpectedly NULL");
1037     }
1038     st->print_cr("%s \"%s\"", owner_desc, currentThread->get_thread_name());

 418     // It isn't clear how to make deadlock detection work correctly if that
 419     // happens.
 420     waitingToLockRawMonitor = jt->current_pending_raw_monitor();
 421 
 422     if (concurrent_locks) {
 423       waitingToLockBlocker = jt->current_park_blocker();
 424     }
 425 
 426     while (waitingToLockMonitor != NULL ||
 427            waitingToLockRawMonitor != NULL ||
 428            waitingToLockBlocker != NULL) {
 429       cycle->add_thread(currentThread);
 430       // Give preference to the raw monitor
 431       if (waitingToLockRawMonitor != NULL) {
 432         Thread* owner = waitingToLockRawMonitor->owner();
 433         if (owner != NULL && // the raw monitor could be released at any time
 434             owner->is_Java_thread()) {
 435           currentThread = owner->as_Java_thread();
 436         }
 437       } else if (waitingToLockMonitor != NULL) {
 438         if (waitingToLockMonitor->has_owner()) {
 439           currentThread = Threads::owning_thread_from_monitor(t_list, waitingToLockMonitor);


 440           if (currentThread == NULL) {
 441             // This function is called at a safepoint so the JavaThread
 442             // that owns waitingToLockMonitor should be findable, but
 443             // if it is not findable, then the previous currentThread is
 444             // blocked permanently. We record this as a deadlock.
 445             num_deadlocks++;
 446 
 447             cycle->set_deadlock(true);
 448 
 449             // add this cycle to the deadlocks list
 450             if (deadlocks == NULL) {
 451               deadlocks = cycle;
 452             } else {
 453               last->set_next(cycle);
 454             }
 455             last = cycle;
 456             cycle = new DeadlockCycle();
 457             break;
 458           }
 459         }

 995         if (owner->is_Java_thread()) {
 996           currentThread = owner->as_Java_thread();
 997           st->print_cr("%s \"%s\"", owner_desc, currentThread->get_thread_name());
 998         } else {
 999           st->print_cr(",\n  which has now been released");
1000         }
1001       } else {
1002         st->print_cr("%s non-Java thread=" PTR_FORMAT, owner_desc, p2i(owner));
1003       }
1004     }
1005 
1006     if (waitingToLockMonitor != NULL) {
1007       st->print("  waiting to lock monitor " INTPTR_FORMAT, p2i(waitingToLockMonitor));
1008       oop obj = waitingToLockMonitor->object();
1009       st->print(" (object " INTPTR_FORMAT ", a %s)", p2i(obj),
1010                  obj->klass()->external_name());
1011 
1012       if (!currentThread->current_pending_monitor_is_from_java()) {
1013         owner_desc = "\n  in JNI, which is held by";
1014       }
1015       currentThread = Threads::owning_thread_from_monitor(t_list, waitingToLockMonitor);

1016       if (currentThread == NULL) {
1017         // The deadlock was detected at a safepoint so the JavaThread
1018         // that owns waitingToLockMonitor should be findable, but
1019         // if it is not findable, then the previous currentThread is
1020         // blocked permanently.
1021         st->print_cr("%s UNKNOWN_owner_addr=" PTR_FORMAT, owner_desc,
1022                   p2i(waitingToLockMonitor->owner()));
1023         continue;
1024       }
1025     } else {
1026       st->print("  waiting for ownable synchronizer " INTPTR_FORMAT ", (a %s)",
1027                 p2i(waitingToLockBlocker),
1028                 waitingToLockBlocker->klass()->external_name());
1029       assert(waitingToLockBlocker->is_a(vmClasses::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass()),
1030              "Must be an AbstractOwnableSynchronizer");
1031       oop ownerObj = java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(waitingToLockBlocker);
1032       currentThread = java_lang_Thread::thread(ownerObj);
1033       assert(currentThread != NULL, "AbstractOwnableSynchronizer owning thread is unexpectedly NULL");
1034     }
1035     st->print_cr("%s \"%s\"", owner_desc, currentThread->get_thread_name());
< prev index next >