In the debug agent threadControl module there is an API called getLocks() that grabs any monitor that may be needed during thread suspension, and then releaseLocks() releases them once thread suspension is done. This is to make sure we don't end up suspending a thread that is holding a monitor that we will need later on. A failure to grab all needed monitors can lead to a deadlock.
Once the monitors are grabbed, we should store the current thread in a global and then assert that no more monitors are grabbed by that thread. This would just require debugMonitorEnter() comparing the global to the current thread. It does however need to allow re-entering already held monitors, which requires tracking entry counts for each monitor. This is being added by JDK-8328866 and can be leveraged once it is in place.
Once the monitors are grabbed, we should store the current thread in a global and then assert that no more monitors are grabbed by that thread. This would just require debugMonitorEnter() comparing the global to the current thread. It does however need to allow re-entering already held monitors, which requires tracking entry counts for each monitor. This is being added by JDK-8328866 and can be leveraged once it is in place.
- relates to
-
JDK-8328866 Add raw monitor rank support to the debug agent
-
- In Progress
-