src/share/vm/services/threadService.cpp
Print this page
rev 4818 : 8016304: ThreadMXBean.getDeadlockedThreads reports bogus deadlocks on JDK 8
Reviewed-by:
*** 325,336 ****
waitingToLockBlocker = jt->current_park_blocker();
}
while (waitingToLockMonitor != NULL || waitingToLockBlocker != NULL) {
cycle->add_thread(currentThread);
if (waitingToLockMonitor != NULL) {
currentThread = Threads::owning_thread_from_monitor_owner(
! (address)waitingToLockMonitor->owner(),
false /* no locking needed */);
if (currentThread == NULL) {
// This function is called at a safepoint so the JavaThread
// that owns waitingToLockMonitor should be findable, but
// if it is not findable, then the previous currentThread is
--- 325,338 ----
waitingToLockBlocker = jt->current_park_blocker();
}
while (waitingToLockMonitor != NULL || waitingToLockBlocker != NULL) {
cycle->add_thread(currentThread);
if (waitingToLockMonitor != NULL) {
+ address currentOwner = (address)waitingToLockMonitor->owner();
+ if (currentOwner != NULL) {
currentThread = Threads::owning_thread_from_monitor_owner(
! currentOwner,
false /* no locking needed */);
if (currentThread == NULL) {
// This function is called at a safepoint so the JavaThread
// that owns waitingToLockMonitor should be findable, but
// if it is not findable, then the previous currentThread is
*** 347,356 ****
--- 349,359 ----
}
last = cycle;
cycle = new DeadlockCycle();
break;
}
+ }
} else {
if (concurrent_locks) {
if (waitingToLockBlocker->is_a(SystemDictionary::abstract_ownable_synchronizer_klass())) {
oop threadObj = java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(waitingToLockBlocker);
currentThread = threadObj != NULL ? java_lang_Thread::thread(threadObj) : NULL;