8150689: Thread dump report "waiting to re-lock in wait()" shows incorrectly

"waiting to re-lock in wait()" is now shown in the frame where relocking is taking place

Reviewed-by: dholmes, dcubed
This commit is contained in:
Patricio Chilano Mateo 2018-11-27 13:39:57 -05:00
parent 5d1cc7fc01
commit 803b9a675b
2 changed files with 4 additions and 22 deletions

View file

@ -2943,7 +2943,6 @@ void JavaThread::print_on(outputStream *st, bool print_extended_info) const {
st->print_cr(" java.lang.Thread.State: %s", java_lang_Thread::thread_status_name(thread_oop)); st->print_cr(" java.lang.Thread.State: %s", java_lang_Thread::thread_status_name(thread_oop));
} }
#ifndef PRODUCT #ifndef PRODUCT
print_thread_state_on(st);
_safepoint_state->print_on(st); _safepoint_state->print_on(st);
#endif // PRODUCT #endif // PRODUCT
if (is_Compiler_thread()) { if (is_Compiler_thread()) {

View file

@ -171,13 +171,15 @@ void javaVFrame::print_lock_info_on(outputStream* st, int frame_count) {
// we are still waiting for notification or timeout. Otherwise if // we are still waiting for notification or timeout. Otherwise if
// we earlier reported java.lang.Thread.State == "BLOCKED (on object // we earlier reported java.lang.Thread.State == "BLOCKED (on object
// monitor)", then we are actually waiting to re-lock the monitor. // monitor)", then we are actually waiting to re-lock the monitor.
// At this level we can't distinguish the two cases to report
// "waited on" rather than "waiting on" for the second case.
StackValueCollection* locs = locals(); StackValueCollection* locs = locals();
if (!locs->is_empty()) { if (!locs->is_empty()) {
StackValue* sv = locs->at(0); StackValue* sv = locs->at(0);
if (sv->type() == T_OBJECT) { if (sv->type() == T_OBJECT) {
Handle o = locs->at(0)->get_obj(); Handle o = locs->at(0)->get_obj();
if (java_lang_Thread::get_thread_status(thread()->threadObj()) ==
java_lang_Thread::BLOCKED_ON_MONITOR_ENTER) {
wait_state = "waiting to re-lock in wait()";
}
print_locked_object_class_name(st, o, wait_state); print_locked_object_class_name(st, o, wait_state);
} }
} else { } else {
@ -234,25 +236,6 @@ void javaVFrame::print_lock_info_on(outputStream* st, int frame_count) {
// disable the extra printing below. // disable the extra printing below.
mark = NULL; mark = NULL;
} }
} else if (frame_count != 0) {
// This is not the first frame so we either own this monitor
// or we owned the monitor before and called wait(). Because
// wait() could have been called on any monitor in a lower
// numbered frame on the stack, we have to check all the
// monitors on the list for this frame.
mark = monitor->owner()->mark();
if (mark->has_monitor() &&
( // we have marked ourself as pending on this monitor
mark->monitor() == thread()->current_pending_monitor() ||
// we are not the owner of this monitor
!mark->monitor()->is_entered(thread())
)) {
lock_state = "waiting to re-lock in wait()";
} else {
// We own the monitor which is not as interesting so
// disable the extra printing below.
mark = NULL;
}
} }
print_locked_object_class_name(st, Handle(THREAD, monitor->owner()), lock_state); print_locked_object_class_name(st, Handle(THREAD, monitor->owner()), lock_state);