8195979: [Graal] crash in src/hotspot/share/runtime/mutex.cpp:1341 when Graal JIT is used
authorkbarrett
Wed, 24 Jan 2018 18:00:36 -0500
changeset 48812 f43576cfb273
parent 48811 58787a1708d2
child 48813 c092a2fbb7c3
8195979: [Graal] crash in src/hotspot/share/runtime/mutex.cpp:1341 when Graal JIT is used Summary: Reduce JNI oopstorage lock ranks to be more special than "special". Reviewed-by: coleenp, acorn, eosterlund
src/hotspot/share/runtime/mutexLocker.cpp
--- a/src/hotspot/share/runtime/mutexLocker.cpp	Wed Jan 24 11:33:18 2018 -0500
+++ b/src/hotspot/share/runtime/mutexLocker.cpp	Wed Jan 24 18:00:36 2018 -0500
@@ -248,10 +248,15 @@
   def(Terminator_lock              , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_sometimes);
   def(VtableStubs_lock             , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_always);
   def(Notify_lock                  , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_always);
-  def(JNIGlobalAlloc_lock          , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_never);
-  def(JNIGlobalActive_lock         , PaddedMutex  , nonleaf-1,   true,  Monitor::_safepoint_check_never);
-  def(JNIWeakAlloc_lock            , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_never);
-  def(JNIWeakActive_lock           , PaddedMutex  , nonleaf-1,   true,  Monitor::_safepoint_check_never);
+  // OopStorage-based JNI may lock the alloc_locks while releasing a handle,
+  // while previous JNI didn't need a lock for handle release.  This runs afoul
+  // of some places which hold other locks while releasing a handle, including
+  // the Patching_lock, which is of "special" rank.  As a temporary workaround,
+  // lower the JNI oopstorage lock ranks to make them super-special.
+  def(JNIGlobalAlloc_lock          , PaddedMutex  , special-1,   true,  Monitor::_safepoint_check_never);
+  def(JNIGlobalActive_lock         , PaddedMutex  , special-2,   true,  Monitor::_safepoint_check_never);
+  def(JNIWeakAlloc_lock            , PaddedMutex  , special-1,   true,  Monitor::_safepoint_check_never);
+  def(JNIWeakActive_lock           , PaddedMutex  , special-2,   true,  Monitor::_safepoint_check_never);
   def(JNICritical_lock             , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_always);     // used for JNI critical regions
   def(AdapterHandlerLibrary_lock   , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_always);