From 5610e1360fdf428b7e5b0049459768c4ea65b6c4 Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Thu, 28 May 2026 22:46:33 +0200 Subject: [PATCH 1/3] fix(liveness): release jweak ref when liveness table overflows or realloc fails PROF-14823 Co-Authored-By: Claude Sonnet 4.6 --- ddprof-lib/src/main/cpp/livenessTracker.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ddprof-lib/src/main/cpp/livenessTracker.cpp b/ddprof-lib/src/main/cpp/livenessTracker.cpp index 61e17f8bc..ed005fc7f 100644 --- a/ddprof-lib/src/main/cpp/livenessTracker.cpp +++ b/ddprof-lib/src/main/cpp/livenessTracker.cpp @@ -361,6 +361,9 @@ void LivenessTracker::track(JNIEnv *env, AllocEvent &event, jint tid, } else { Log::debug("Cannot add sampled object to Liveness tracking table, " "resize attempt failed, the table is overflowing"); + _table_lock.unlock(); + env->DeleteWeakGlobalRef(ref); + return; } } @@ -370,6 +373,7 @@ void LivenessTracker::track(JNIEnv *env, AllocEvent &event, jint tid, } else { Log::debug("Cannot add sampled object to Liveness tracking table, it's " "overflowing"); + env->DeleteWeakGlobalRef(ref); } } } From be3fe3bb21358d4f61e2ca69bcd18830a5b398ff Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Fri, 29 May 2026 00:01:55 +0200 Subject: [PATCH 2/3] fix(liveness): plug third jweak leak path and fix skipped-reset on realloc failure Co-Authored-By: Claude Sonnet 4.6 --- ddprof-lib/src/main/cpp/livenessTracker.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ddprof-lib/src/main/cpp/livenessTracker.cpp b/ddprof-lib/src/main/cpp/livenessTracker.cpp index ed005fc7f..b5c17925e 100644 --- a/ddprof-lib/src/main/cpp/livenessTracker.cpp +++ b/ddprof-lib/src/main/cpp/livenessTracker.cpp @@ -363,6 +363,7 @@ void LivenessTracker::track(JNIEnv *env, AllocEvent &event, jint tid, "resize attempt failed, the table is overflowing"); _table_lock.unlock(); env->DeleteWeakGlobalRef(ref); + skipped = 0; return; } } @@ -375,6 +376,8 @@ void LivenessTracker::track(JNIEnv *env, AllocEvent &event, jint tid, "overflowing"); env->DeleteWeakGlobalRef(ref); } + } else { + env->DeleteWeakGlobalRef(ref); } } skipped = 0; // reset the subsampling skipped bytes From 4b43ca2e11285d7b7bb54806082d11aab6ba3eb9 Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Fri, 29 May 2026 00:10:09 +0200 Subject: [PATCH 3/3] fix(liveness): retry insert after realloc failure if cleanup freed slots Co-Authored-By: Claude Sonnet 4.6 --- ddprof-lib/src/main/cpp/livenessTracker.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ddprof-lib/src/main/cpp/livenessTracker.cpp b/ddprof-lib/src/main/cpp/livenessTracker.cpp index b5c17925e..840f6c606 100644 --- a/ddprof-lib/src/main/cpp/livenessTracker.cpp +++ b/ddprof-lib/src/main/cpp/livenessTracker.cpp @@ -361,10 +361,6 @@ void LivenessTracker::track(JNIEnv *env, AllocEvent &event, jint tid, } else { Log::debug("Cannot add sampled object to Liveness tracking table, " "resize attempt failed, the table is overflowing"); - _table_lock.unlock(); - env->DeleteWeakGlobalRef(ref); - skipped = 0; - return; } }