RFR: 8369622: GlobalChunkPoolMutex is recursively locked during error handling

Afshin Zafari azafari at openjdk.org
Tue Oct 21 11:39:15 UTC 2025


On Fri, 17 Oct 2025 17:04:58 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

> This change disables recursive locking for the ChunkPoolLocker during error handling for NMT callers.  The patch is written by Johan as an alternative to supporting another recursive locker for this lock.
> Tested with tier1-4, tier5 on aarch64 (product and debug).

Thank you for taking this PR.
I could reproduce the deadlock by this change: 

--- a/test/hotspot/gtest/nmt/test_nmt_buffer_overflow_detection.cpp
+++ b/test/hotspot/gtest/nmt/test_nmt_buffer_overflow_detection.cpp
@@ -23,6 +23,7 @@
  */
 
 #include "memory/allocation.hpp"
+#include "memory/arena.hpp"
 #include "nmt/memTracker.hpp"
 #include "runtime/os.hpp"
 #include "sanitizers/address.hpp"
@@ -142,6 +143,21 @@ DEFINE_TEST(test_corruption_on_realloc_growing, COMMON_NMT_HEAP_CORRUPTION_MESSA
 static void test_corruption_on_realloc_shrinking()  { test_corruption_on_realloc(0x11, 0x10); }
 DEFINE_TEST(test_corruption_on_realloc_shrinking, COMMON_NMT_HEAP_CORRUPTION_MESSAGE_PREFIX);
 
+
+static void test_chunkpool_lock() {
+  if (!MemTracker::enabled()) {
+    tty->print_cr("Skipped");
+    return;
+  }
+  PrintNMTStatistics = true;
+  {
+    ChunkPoolLocker cpl;
+    char* mem = (char*)os::malloc(100, mtTest);
+    memset(mem - 16, 0, 100 + 16 + 2);
+    os::free(mem);
+  }
+}
+DEFINE_TEST(test_chunkpool_lock, COMMON_NMT_HEAP_CORRUPTION_MESSAGE_PREFIX);
 ///////



We can add it to the tests if you found it useful.

-------------

PR Review: https://git.openjdk.org/jdk/pull/27869#pullrequestreview-3360133902


More information about the hotspot-runtime-dev mailing list