On Mon, 25 Sep 2023 19:59:32 GMT, Roman Kennke <rken...@openjdk.org> wrote:

> The specific race here is that SA sees an anonymously locked ObjectMonitor 
> and tries to find the owning thread, and fails, presumably because that 
> thread has moved on and unlocked the object in the meantime.

But you said that when T1 starts the process of unlocking O, it sees the 
anonymous owner and it sets T1 as the owner before unlocking and handing off to 
T2. So I don't see how T1 could have "moved on". If T2 is blocked on O and O an 
anonymous owner, then T1 must still own it. 

SA always deals with a snapshot of the JVM state. Once SA attaches, no threads 
are running. So if O has an anonymous owner, you don't have to worry about the 
owner releasing the monitor while you are looking for the owner.

The question then becomes is there a short window while releasing the monitor 
that O still shows up as having an anonymous owner, but T1 has already released 
it. From your description of the order of things, this doesn't seem possible.

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

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

Reply via email to