JDK-8312368 : Improve troubleshooting of GCLocker-induced deadlocks
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • Submitted: 2023-07-19
  • Updated: 2023-07-19
Related Reports
Relates :  
Description
Currently troubleshooting of deadlocks caused by GCLocker is hard.
The regular diagnostic tools like jstack fail. Jhsdb can produce java stack traces, and sometimes can also produce native stacks. Still, analyzing the failures requires a deep dive into the hotspot source code.

We could change the assert in GCLocker::stall_until_clear() to a guarantee. This will crash the JVM instead of deadlocking, and will produce a stack trace that will point to the area where the deadlock was triggered.

In order to avoid having these failures reported to us, we could change the failure message to something like "A JNI Critical API deadlock has occurred - please run with -Xcheck:jni to diagnose" (credit to [~dholmes] for suggestion)

To reproduce:
create a JNI function, call GetPrimitiveArrayCritical, then repeatedly call NewObject until GC deadlocks.

See JDK-8307185 (and duplicates) for an example of related bug.
Comments
Also, Xcheck:jni prints out the following warning without a stack trace: "Warning: Calling other JNI functions in the scope of Get/ReleasePrimitiveArrayCritical or Get/ReleaseStringCritical" IMO a stack trace would also be helpful here.
19-07-2023