< prev index next >

src/hotspot/share/services/threadService.cpp

Print this page

 438     // It isn't clear how to make deadlock detection work correctly if that
 439     // happens.
 440     waitingToLockRawMonitor = jt->current_pending_raw_monitor();
 441 
 442     if (concurrent_locks) {
 443       waitingToLockBlocker = jt->current_park_blocker();
 444     }
 445 
 446     while (waitingToLockMonitor != NULL ||
 447            waitingToLockRawMonitor != NULL ||
 448            waitingToLockBlocker != NULL) {
 449       cycle->add_thread(currentThread);
 450       // Give preference to the raw monitor
 451       if (waitingToLockRawMonitor != NULL) {
 452         Thread* owner = waitingToLockRawMonitor->owner();
 453         if (owner != NULL && // the raw monitor could be released at any time
 454             owner->is_Java_thread()) {
 455           currentThread = JavaThread::cast(owner);
 456         }
 457       } else if (waitingToLockMonitor != NULL) {
 458         address currentOwner = (address)waitingToLockMonitor->owner();
 459         if (currentOwner != NULL) {
 460           currentThread = Threads::owning_thread_from_monitor_owner(t_list,
 461                                                                     currentOwner);
 462           if (currentThread == NULL) {
 463             // This function is called at a safepoint so the JavaThread
 464             // that owns waitingToLockMonitor should be findable, but
 465             // if it is not findable, then the previous currentThread is
 466             // blocked permanently. We record this as a deadlock.
 467             num_deadlocks++;
 468 
 469             // add this cycle to the deadlocks list
 470             if (deadlocks == NULL) {
 471               deadlocks = cycle;
 472             } else {
 473               last->set_next(cycle);
 474             }
 475             last = cycle;
 476             cycle = new DeadlockCycle();
 477             break;
 478           }
 479         }
 480       } else {
 481         if (concurrent_locks) {

1035         if (owner->is_Java_thread()) {
1036           currentThread = JavaThread::cast(owner);
1037           st->print_cr("%s \"%s\"", owner_desc, currentThread->name());
1038         } else {
1039           st->print_cr(",\n  which has now been released");
1040         }
1041       } else {
1042         st->print_cr("%s non-Java thread=" PTR_FORMAT, owner_desc, p2i(owner));
1043       }
1044     }
1045 
1046     if (waitingToLockMonitor != NULL) {
1047       st->print("  waiting to lock monitor " INTPTR_FORMAT, p2i(waitingToLockMonitor));
1048       oop obj = waitingToLockMonitor->object();
1049       st->print(" (object " INTPTR_FORMAT ", a %s)", p2i(obj),
1050                  obj->klass()->external_name());
1051 
1052       if (!currentThread->current_pending_monitor_is_from_java()) {
1053         owner_desc = "\n  in JNI, which is held by";
1054       }
1055       currentThread = Threads::owning_thread_from_monitor_owner(t_list,
1056                                                                 (address)waitingToLockMonitor->owner());
1057       if (currentThread == NULL) {
1058         // The deadlock was detected at a safepoint so the JavaThread
1059         // that owns waitingToLockMonitor should be findable, but
1060         // if it is not findable, then the previous currentThread is
1061         // blocked permanently.
1062         st->print_cr("%s UNKNOWN_owner_addr=" PTR_FORMAT, owner_desc,
1063                   p2i(waitingToLockMonitor->owner()));
1064         continue;
1065       }
1066     } else {
1067       st->print("  waiting for ownable synchronizer " INTPTR_FORMAT ", (a %s)",
1068                 p2i(waitingToLockBlocker),
1069                 waitingToLockBlocker->klass()->external_name());
1070       assert(waitingToLockBlocker->is_a(vmClasses::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass()),
1071              "Must be an AbstractOwnableSynchronizer");
1072       oop ownerObj = java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(waitingToLockBlocker);
1073       currentThread = java_lang_Thread::thread(ownerObj);
1074       assert(currentThread != NULL, "AbstractOwnableSynchronizer owning thread is unexpectedly NULL");
1075     }
1076     st->print_cr("%s \"%s\"", owner_desc, currentThread->name());

 438     // It isn't clear how to make deadlock detection work correctly if that
 439     // happens.
 440     waitingToLockRawMonitor = jt->current_pending_raw_monitor();
 441 
 442     if (concurrent_locks) {
 443       waitingToLockBlocker = jt->current_park_blocker();
 444     }
 445 
 446     while (waitingToLockMonitor != NULL ||
 447            waitingToLockRawMonitor != NULL ||
 448            waitingToLockBlocker != NULL) {
 449       cycle->add_thread(currentThread);
 450       // Give preference to the raw monitor
 451       if (waitingToLockRawMonitor != NULL) {
 452         Thread* owner = waitingToLockRawMonitor->owner();
 453         if (owner != NULL && // the raw monitor could be released at any time
 454             owner->is_Java_thread()) {
 455           currentThread = JavaThread::cast(owner);
 456         }
 457       } else if (waitingToLockMonitor != NULL) {
 458         if (waitingToLockMonitor->is_owner_anonymous() || waitingToLockMonitor->owner() != NULL) {
 459           currentThread = Threads::owning_thread_from_monitor(t_list, waitingToLockMonitor);


 460           if (currentThread == NULL) {
 461             // This function is called at a safepoint so the JavaThread
 462             // that owns waitingToLockMonitor should be findable, but
 463             // if it is not findable, then the previous currentThread is
 464             // blocked permanently. We record this as a deadlock.
 465             num_deadlocks++;
 466 
 467             // add this cycle to the deadlocks list
 468             if (deadlocks == NULL) {
 469               deadlocks = cycle;
 470             } else {
 471               last->set_next(cycle);
 472             }
 473             last = cycle;
 474             cycle = new DeadlockCycle();
 475             break;
 476           }
 477         }
 478       } else {
 479         if (concurrent_locks) {

1033         if (owner->is_Java_thread()) {
1034           currentThread = JavaThread::cast(owner);
1035           st->print_cr("%s \"%s\"", owner_desc, currentThread->name());
1036         } else {
1037           st->print_cr(",\n  which has now been released");
1038         }
1039       } else {
1040         st->print_cr("%s non-Java thread=" PTR_FORMAT, owner_desc, p2i(owner));
1041       }
1042     }
1043 
1044     if (waitingToLockMonitor != NULL) {
1045       st->print("  waiting to lock monitor " INTPTR_FORMAT, p2i(waitingToLockMonitor));
1046       oop obj = waitingToLockMonitor->object();
1047       st->print(" (object " INTPTR_FORMAT ", a %s)", p2i(obj),
1048                  obj->klass()->external_name());
1049 
1050       if (!currentThread->current_pending_monitor_is_from_java()) {
1051         owner_desc = "\n  in JNI, which is held by";
1052       }
1053       currentThread = Threads::owning_thread_from_monitor(t_list, waitingToLockMonitor);

1054       if (currentThread == NULL) {
1055         // The deadlock was detected at a safepoint so the JavaThread
1056         // that owns waitingToLockMonitor should be findable, but
1057         // if it is not findable, then the previous currentThread is
1058         // blocked permanently.
1059         st->print_cr("%s UNKNOWN_owner_addr=" PTR_FORMAT, owner_desc,
1060                   p2i(waitingToLockMonitor->owner()));
1061         continue;
1062       }
1063     } else {
1064       st->print("  waiting for ownable synchronizer " INTPTR_FORMAT ", (a %s)",
1065                 p2i(waitingToLockBlocker),
1066                 waitingToLockBlocker->klass()->external_name());
1067       assert(waitingToLockBlocker->is_a(vmClasses::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass()),
1068              "Must be an AbstractOwnableSynchronizer");
1069       oop ownerObj = java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(waitingToLockBlocker);
1070       currentThread = java_lang_Thread::thread(ownerObj);
1071       assert(currentThread != NULL, "AbstractOwnableSynchronizer owning thread is unexpectedly NULL");
1072     }
1073     st->print_cr("%s \"%s\"", owner_desc, currentThread->name());
< prev index next >