From bd918f49d29bcbc699e07b4ef8d23cfe1abd32df Mon Sep 17 00:00:00 2001 From: Roman Kennke Date: Fri, 29 Sep 2023 11:14:13 +0000 Subject: [PATCH] 8316401: sun/tools/jhsdb/JStackStressTest.java failed with "InternalError: We should have found a thread that owns the anonymous lock" Reviewed-by: cjplummer, dholmes --- .../share/classes/sun/jvm/hotspot/runtime/Threads.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java index daf00972676..4a40525b78a 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java @@ -241,7 +241,11 @@ public class Threads { return thread; } } - throw new InternalError("We should have found a thread that owns the anonymous lock"); + // We should have found the owner, however, as the VM could be in any state, including the middle + // of performing GC, it is not always possible to do so. Just return null if we can't locate it. + System.out.println("Warning: We failed to find a thread that owns an anonymous lock. This is likely"); + System.out.println("due to the JVM currently running a GC. Locking information may not be accurate."); + return null; } // Owner can only be threads at this point. Address o = monitor.owner();