RFR: 8316401: sun/tools/jhsdb/JStackStressTest.java failed with "InternalError: We should have found a thread that owns the anonymous lock"

David Holmes dholmes at openjdk.org
Tue Sep 26 02:37:15 UTC 2023


On Tue, 26 Sep 2023 02:30:25 GMT, David Holmes <dholmes at openjdk.org> wrote:

>>> Ah! I guess we get used to talking about "at a safepoint" when we really mean "at a fixed point in time". So the VM is not necessarily at a safepoint, but everything is fixed. So invariants may not hold, but the state cannot change.
>> 
>> Correct!
>> 
>>> So in the current context the anonymous owner should be found ...
>> 
>> That's what I concluded based on Roman's description of how things work.
>> 
>>>  I guess the question to be answered is how the code tries to find an anonymous owner? I'm not sure how you can find it.
>> 
>> I'm not sure yet. I'll need to have a look.
>
> AFAICS we update the owner to the real thread before we remove the object from the lock stack. So if we see the object monitor is anonymously owned then we should find the monitor object in a thread's lockstack.

Correction, there is one code path where we pop the lockstack first and then update the owner:

ObjectMonitor* monitor = inflate(current, object, inflate_cause_vm_internal);
  if (LockingMode == LM_LIGHTWEIGHT && monitor->is_owner_anonymous()) {
    // It must be owned by us. Pop lock object from lock stack.
    LockStack& lock_stack = current->lock_stack();
    oop popped = lock_stack.pop();
    assert(popped == object, "must be owned by this thread");
    monitor->set_owner_from_anonymous(current);
  }
  monitor->exit(current);

we should probably do this the other way around.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15907#discussion_r1336558790


More information about the serviceability-dev mailing list