Mercurial > hg > heapstats
changeset 187:14ea8c5a07c9
Bug 3225: JVM may hang when deadlock detector and safepoint are conflicted
Reviewed-by: ykubota
https://github.com/HeapStats/heapstats/pull/48
author | Yasumasa Suenaga <yasuenag@gmail.com> |
---|---|
date | Wed, 09 Nov 2016 21:15:19 +0900 |
parents | 9798887d2ade |
children | 44059a9aa639 |
files | ChangeLog agent/src/heapstats-engines/deadlockFinder.cpp |
diffstat | 2 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Nov 08 22:34:43 2016 +0900 +++ b/ChangeLog Wed Nov 09 21:15:19 2016 +0900 @@ -1,3 +1,7 @@ +2016-11-09 Yasumasa Suenaga <yasuenag@gmail.com> + + * Bug 3225: JVM may hang when deadlock detector and safepoint are conflicted + 2016-11-08 Yasumasa Suenaga <yasuenag@gmail.com> * Bug 3223: Cannot set empty value to signal setting
--- a/agent/src/heapstats-engines/deadlockFinder.cpp Tue Nov 08 22:34:43 2016 +0900 +++ b/agent/src/heapstats-engines/deadlockFinder.cpp Wed Nov 09 21:15:19 2016 +0900 @@ -358,6 +358,17 @@ } if (*status == THREAD_IN_VM) { + /* + * Reset "_thread_state". + * + * CAUTION!! + * According to the comment of Monitor::lock_without_safepoint_check() in + * hotspot/src/share/vm/runtime/mutex.cpp: + * If this is called with thread state set to be in VM, the safepoint + * synchronization code will deadlock! + */ + *status = original_status; + bool needLock = !vmFunc->MonitorOwnedBySelf(thread_lock); /* @@ -373,8 +384,6 @@ } } - /* Reset "_thread_state". */ - *status = original_status; /* Reset "_safepoint_state". */ vmFunc->ThreadSafepointStateDestroy(thisThreadPtr); vmFunc->ThreadSafepointStateCreate(thisThreadPtr);