8150689: Thread dump report "waiting to re-lock in wait()" shows incorrectly
Summary: "waiting to re-lock in wait()" is now shown in the frame where relocking is taking place
Reviewed-by: dholmes, dcubed
--- a/src/hotspot/share/runtime/thread.cpp Tue Nov 27 11:28:47 2018 -0800
+++ b/src/hotspot/share/runtime/thread.cpp Tue Nov 27 13:39:57 2018 -0500
@@ -2943,7 +2943,6 @@
st->print_cr(" java.lang.Thread.State: %s", java_lang_Thread::thread_status_name(thread_oop));
}
#ifndef PRODUCT
- print_thread_state_on(st);
_safepoint_state->print_on(st);
#endif // PRODUCT
if (is_Compiler_thread()) {
--- a/src/hotspot/share/runtime/vframe.cpp Tue Nov 27 11:28:47 2018 -0800
+++ b/src/hotspot/share/runtime/vframe.cpp Tue Nov 27 13:39:57 2018 -0500
@@ -171,13 +171,15 @@
// we are still waiting for notification or timeout. Otherwise if
// we earlier reported java.lang.Thread.State == "BLOCKED (on object
// 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();
if (!locs->is_empty()) {
StackValue* sv = locs->at(0);
if (sv->type() == T_OBJECT) {
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);
}
} else {
@@ -234,25 +236,6 @@
// disable the extra printing below.
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);