< prev index next >

src/hotspot/share/services/threadService.cpp

Print this page

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

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

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


 435           if (currentThread == NULL) {
 436             // This function is called at a safepoint so the JavaThread
 437             // that owns waitingToLockMonitor should be findable, but
 438             // if it is not findable, then the previous currentThread is
 439             // blocked permanently. We record this as a deadlock.
 440             num_deadlocks++;
 441 


 442             // add this cycle to the deadlocks list
 443             if (deadlocks == NULL) {
 444               deadlocks = cycle;
 445             } else {
 446               last->set_next(cycle);
 447             }
 448             last = cycle;
 449             cycle = new DeadlockCycle();
 450             break;
 451           }
 452         }
 453       } else {
 454         if (concurrent_locks) {
 455           if (waitingToLockBlocker->is_a(vmClasses::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass())) {
 456             oop threadObj = java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(waitingToLockBlocker);
 457             // This JavaThread (if there is one) is protected by the
 458             // ThreadsListSetter in VM_FindDeadlocks::doit().
 459             currentThread = threadObj != NULL ? java_lang_Thread::thread(threadObj) : NULL;
 460           } else {
 461             currentThread = NULL;

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

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