On Tue, 26 Sep 2023 01:25:59 GMT, David Holmes <dhol...@openjdk.org> wrote:
>> To expand if deadlock detection does not run at a safepoint then this logic >> is non-atomic and completely broken: >> >> threads = VM.getVM().getThreads(); >> heap = VM.getVM().getObjectHeap(); >> createThreadTable(); // calls getThreads() again >> >> Without a stable VM you could have three almost completely different set of >> threads when each of these statements run! > > If the SA is working from a snapshot then it has to create that snapshot > atomically. It can't snapshot the threads, then snapshot the heap. Correction to above: threads = VM.getVM().getThreads(); heap = VM.getVM().getObjectHeap(); createThreadTable(); // calls getThreads() again The VM caches the set of threads ie the snapshot, so three sets are not possible. But AFAICS the thread snapshot and heap snapshot are not atomic, so the set of threads could have changed, and the state of threads also. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15907#discussion_r1336530626