On Wed, 7 Apr 2021 13:08:47 GMT, Richard Reingruber <rr...@openjdk.org> wrote:

>> Today the ThreadBlockInVM tbivm(current); is inside scope of 
>> JavaThreadBlockedOnMonitorEnterState jtbmes(current, this);.
>> So this can happen today also.
>> 
>> If you are context switch just before 
>> current->set_current_pending_monitor(NULL);.
>> Someone suspends you and look at those states.
>> 
>> If you agree that the issue is preexisting I prefer handling that outside 
>> scope of this.
>
>> Today the ThreadBlockInVM tbivm(current); is inside scope of 
>> JavaThreadBlockedOnMonitorEnterState jtbmes(current, this);.
>> So this can happen today also.
>> 
>> If you are context switch just before 
>> current->set_current_pending_monitor(NULL);.
>> Someone suspends you and look at those states.
>> 
> 
> You mean the JVMTI agent suspends the current thread and then observes that 
> the
> thread state first has the attribute 
> JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER and
> in a later call it does not have it anymore (~ThreadBlockInVM doesn't check 
> for
> suspend)? Yes that's problematic too.
> 
> With the new code we could remain suspended with
> JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER. I think the OM would not be
> reported as owned monitor but another thread could not lock it.
> 
>> If you agree that the issue is preexisting I prefer handling that outside 
>> scope of this.
> 
> I'm ok with that.
> 
> A simple solution could then be making use of ThreadBlockInVM. When returning
> from EnterI in L413 we would set a rollback function in the HandshakeState 
> which
> can be called in HandshakeState::suspend_in_handshake() to exit the OM.

I'm mean the state you describe will be seen on that line:
- The current thread is set as owner in ObjectMonitor::_owner
- The thread state will still be JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER 
because of the JavaThreadBlockedOnMonitorEnterState in L389.
- Thread::_current_pending_monitor has not been reset to NULL.

Will be seen while we are context while in blocked state before clearing the 
_current_pending_monitor.

Ok good.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3191

Reply via email to