8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'

Add a !owner check for 'waiting to lock' to catch current_pending_monitor corner cases.

Co-authored-by: Krystal Mok <rednaxelafx@gmail.com>
Co-authored-by: Zhengyu Gu <zhengyu.gu@oracle.com>
Reviewed-by: dholmes, sspitsyn, kmo, zgu
This commit is contained in:
Daniel D. Daugherty 2014-05-30 07:20:51 -07:00
parent 5ff7186a1c
commit ad6d8d6abd
4 changed files with 421 additions and 1 deletions

View file

@ -199,6 +199,7 @@ void javaVFrame::print_lock_info_on(outputStream* st, int frame_count) {
continue;
}
if (monitor->owner() != NULL) {
// the monitor is associated with an object, i.e., it is locked
// First, assume we have the monitor locked. If we haven't found an
// owned monitor before and this is the first frame, then we need to
@ -209,7 +210,11 @@ void javaVFrame::print_lock_info_on(outputStream* st, int frame_count) {
if (!found_first_monitor && frame_count == 0) {
markOop mark = monitor->owner()->mark();
if (mark->has_monitor() &&
mark->monitor() == thread()->current_pending_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 lock";
}
}