On Tue, 26 Sep 2023 01:07:32 GMT, David Holmes <dhol...@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. > > Surely jstack thread dump and deadlock check _has_ to run at a safepoint? Also isn't "anonymous locking" an intermediate step in monitor inflation? The inflated monitor becomes anonymously owned until the real owner sees it has been inflated and updates the ownership accordingly. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15907#discussion_r1336520272