comparison src/share/vm/runtime/vframe.cpp @ 17965:4a1062dc52d1

8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock' Summary: Add a !owner check for 'waiting to lock' to catch current_pending_monitor corner cases. Reviewed-by: dholmes, sspitsyn, kmo, zgu Contributed-by: rednaxelafx@gmail.com, zhengyu.gu@oracle.com, daniel.daugherty@oracle.com
author dcubed
date Wed, 04 Jun 2014 06:25:53 -0700
parents 78bbf4d43a14
children 52b4284cb496 c204e2044c29
comparison
equal deleted inserted replaced
17964:660b3f6bf7d7 17965:4a1062dc52d1
197 } 197 }
198 } 198 }
199 continue; 199 continue;
200 } 200 }
201 if (monitor->owner() != NULL) { 201 if (monitor->owner() != NULL) {
202 // the monitor is associated with an object, i.e., it is locked
202 203
203 // First, assume we have the monitor locked. If we haven't found an 204 // First, assume we have the monitor locked. If we haven't found an
204 // owned monitor before and this is the first frame, then we need to 205 // owned monitor before and this is the first frame, then we need to
205 // see if we have completed the lock or we are blocked trying to 206 // see if we have completed the lock or we are blocked trying to
206 // acquire it - we can only be blocked if the monitor is inflated 207 // acquire it - we can only be blocked if the monitor is inflated
207 208
208 const char *lock_state = "locked"; // assume we have the monitor locked 209 const char *lock_state = "locked"; // assume we have the monitor locked
209 if (!found_first_monitor && frame_count == 0) { 210 if (!found_first_monitor && frame_count == 0) {
210 markOop mark = monitor->owner()->mark(); 211 markOop mark = monitor->owner()->mark();
211 if (mark->has_monitor() && 212 if (mark->has_monitor() &&
212 mark->monitor() == thread()->current_pending_monitor()) { 213 ( // we have marked ourself as pending on this monitor
214 mark->monitor() == thread()->current_pending_monitor() ||
215 // we are not the owner of this monitor
216 !mark->monitor()->is_entered(thread())
217 )) {
213 lock_state = "waiting to lock"; 218 lock_state = "waiting to lock";
214 } 219 }
215 } 220 }
216 221
217 found_first_monitor = true; 222 found_first_monitor = true;