From 7cf8f9ffee25ee574b596888eb063924984cd0c6 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Wed, 15 Oct 2025 13:35:03 -0700 Subject: [PATCH 1/9] 8321687: Test vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/TestDescription.java failed: JVMTI_ERROR_THREAD_NOT_ALIVE --- .../contention/TC03/tc03t002/tc03t002.cpp | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp index 11c74e3a9e2c4..39db6434226bb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,9 @@ static threadDesc *threadList = nullptr; static jint threads_count = 0; static int numberOfDeadlocks = 0; +static const char* thread_name_prefix = "Debugee Thread"; +static size_t thread_name_prefix_len = strlen(thread_name_prefix); + /* ========================================================================== */ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { @@ -103,6 +106,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { int tDfn = 0, gDfn = 0; int pThread, cThread; int i; + int debuggee_thread_cnt = 0; NSK_DISPLAY0("Create threadList\n"); @@ -127,16 +131,25 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); - threadList[i].thread = threads[i]; - threadList[i].dfn = -1; - threadList[i].name = info.name; + if (!strncmp(info.name, thread_name_prefix, thread_name_prefix_len)) { + NSK_DISPLAY1("Skipping thread %s\n", info.name); + if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)info.name))) + return NSK_FALSE; + continue; + } + + threadList[debuggee_thread_cnt].thread = threads[i]; + threadList[debuggee_thread_cnt].dfn = -1; + threadList[debuggee_thread_cnt].name = info.name; + debuggee_thread_cnt++; } /* deallocate thread list */ if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) return NSK_FALSE; - for (i = 0; i < threads_count; i++) { + for (i = 0; i < debuggee_thread_cnt; i++) { + if (threadList[i].dfn < 0) { tDfn = gDfn; threadList[i].dfn = gDfn++; From 385b3e0029c4b380079d5b3ee7e23ebe198993ea Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Wed, 15 Oct 2025 15:39:23 -0700 Subject: [PATCH 2/9] updated after feedback --- .../nsk/jvmti/scenarios/contention/TC03/tc03t002.java | 5 +++-- .../jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002.java index f4ca83c0b5461..97c07acc7845b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002.java @@ -104,7 +104,8 @@ public int runIt(String argv[], PrintStream out) { /* =================================================================== */ class tc03t002Thread extends Thread { - + // The thread name prefix is used to find thread from jvmti agent. + final static String threadNamePrefix = "Debuggee Thread"; static Wicket startingBarrier = new Wicket(3); static Wicket lockingBarrier = new Wicket(3); Wicket waitingBarrier = new Wicket(); @@ -112,7 +113,7 @@ class tc03t002Thread extends Thread { Object lock2; public tc03t002Thread(Object o1, Object o2) { - super("Debuggee Thread " + o1 + o2); + super(threadNamePrefix + " " + o1 + o2); lock1 = o1; lock2 = o2; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp index 39db6434226bb..30511e0362d1d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp @@ -45,8 +45,8 @@ static threadDesc *threadList = nullptr; static jint threads_count = 0; static int numberOfDeadlocks = 0; -static const char* thread_name_prefix = "Debugee Thread"; -static size_t thread_name_prefix_len = strlen(thread_name_prefix); +static const char* THREAD_NAME_PREFIX = "Debugee Thread"; +static const size_t THREAD_NAME_PREFIX_LEN = strlen(THREAD_NAME_PREFIX); /* ========================================================================== */ @@ -131,7 +131,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); - if (!strncmp(info.name, thread_name_prefix, thread_name_prefix_len)) { + if (!strncmp(info.name, THREAD_NAME_PREFIX, THREAD_NAME_PREFIX_LEN)) { NSK_DISPLAY1("Skipping thread %s\n", info.name); if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)info.name))) return NSK_FALSE; From 80fc4d55487b412fd8db17b7c8857cd175f9f162 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Wed, 15 Oct 2025 16:53:48 -0700 Subject: [PATCH 3/9] added one more test --- .../jvmti/scenarios/contention/TC03/tc03t001.java | 6 ++++-- .../scenarios/contention/TC03/tc03t001/tc03t001.cpp | 13 ++++++++++++- .../jvmti/scenarios/contention/TC03/tc03t002.java | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001.java index 4c7905809d978..eb202c87ef3df 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -123,6 +123,8 @@ public int runIt(String argv[], PrintStream out) { /* =================================================================== */ class tc03t001Thread extends Thread { + // The thread name prefix is used to find thread from jvmti agent. + final static String threadNamePrefix = "Debuggee Thread"; Object lock1; Object lock2; @@ -130,7 +132,7 @@ class tc03t001Thread extends Thread { int lock2Counter = 0; public tc03t001Thread(Object o1, Object o2) { - super("Debuggee Thread " + o1 + o2); + super(threadNamePrefix + " " + o1 + o2); lock1 = o1; lock2 = o2; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp index ff7d346d237a1..74591eec6681f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,9 @@ static threadDesc *threadList = nullptr; static jint threads_count = 0; static int numberOfDeadlocks = 0; +static const char* THREAD_NAME_PREFIX = "Debugee Thread"; +static const size_t THREAD_NAME_PREFIX_LEN = strlen(THREAD_NAME_PREFIX); + /* ========================================================================== */ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { @@ -103,6 +106,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { int tDfn = 0, gDfn = 0; int pThread, cThread; int i; + int debuggee_thread_cnt = 0; NSK_DISPLAY0("Create threadList\n"); @@ -127,6 +131,13 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); + if (!strncmp(info.name, THREAD_NAME_PREFIX, THREAD_NAME_PREFIX_LEN)) { + NSK_DISPLAY1("Skipping thread %s\n", info.name); + if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)info.name))) + return NSK_FALSE; + continue; + } + threadList[i].thread = threads[i]; threadList[i].dfn = -1; threadList[i].name = info.name; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002.java index 97c07acc7845b..852b915acd745 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it From fc0cf81d4986c2fb726160c1ec1a9385f90c8270 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Wed, 15 Oct 2025 17:34:38 -0700 Subject: [PATCH 4/9] fixed applied --- .../jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp index 74591eec6681f..2641d8c39120f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp @@ -137,10 +137,10 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_FALSE; continue; } - - threadList[i].thread = threads[i]; - threadList[i].dfn = -1; - threadList[i].name = info.name; + threadList[debuggee_thread_cnt].thread = threads[i]; + threadList[debuggee_thread_cnt].dfn = -1; + threadList[debuggee_thread_cnt].name = info.name; + debuggee_thread_cnt++; } /* deallocate thread list */ From bc31117ee9cf2969a3d9278b2382b781db37e078 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Wed, 15 Oct 2025 17:36:57 -0700 Subject: [PATCH 5/9] fix --- .../nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp index 2641d8c39120f..cdc6cb75c958d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp @@ -147,7 +147,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) return NSK_FALSE; - for (i = 0; i < threads_count; i++) { + for (i = 0; i < debuggee_thread_cnt; i++) { if (threadList[i].dfn < 0) { tDfn = gDfn; threadList[i].dfn = gDfn++; From e70b88418bbab5647eeb22e0194269cedb9b5019 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Wed, 15 Oct 2025 17:38:04 -0700 Subject: [PATCH 6/9] space added --- .../nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp index cdc6cb75c958d..a5c019c56bc66 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp @@ -137,6 +137,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_FALSE; continue; } + threadList[debuggee_thread_cnt].thread = threads[i]; threadList[debuggee_thread_cnt].dfn = -1; threadList[debuggee_thread_cnt].name = info.name; From 4833e33b45333eac5ff2d19f9a43eb0d97804385 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Thu, 16 Oct 2025 19:14:23 -0700 Subject: [PATCH 7/9] the count variables are corrected --- .../contention/TC03/tc03t001/tc03t001.cpp | 18 +++++++++--------- .../contention/TC03/tc03t002/tc03t002.cpp | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp index a5c019c56bc66..1ea8d8e074aae 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp @@ -42,7 +42,7 @@ static jlong timeout = 0; /* test objects */ static threadDesc *threadList = nullptr; -static jint threads_count = 0; +static jint debuggee_threads_cnt = 0; static int numberOfDeadlocks = 0; static const char* THREAD_NAME_PREFIX = "Debugee Thread"; @@ -77,7 +77,7 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { return NSK_FALSE; if (usageInfo.owner == nullptr) break; - for (cThread = 0; cThread < threads_count; cThread++) { + for (cThread = 0; cThread < debuggee_threads_cnt; cThread++) { if (jni->IsSameObject(threadList[cThread].thread, usageInfo.owner)) break; } @@ -87,7 +87,7 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { if (usageInfo.notify_waiters != nullptr) { jvmti->Deallocate((unsigned char*)usageInfo.notify_waiters); } - if (!NSK_VERIFY(cThread != threads_count)) + if (!NSK_VERIFY(cThread != debuggee_threads_cnt)) return NSK_FALSE; NSK_DISPLAY1(" which is held by \"%s\"\n", threadList[cThread].name); @@ -106,7 +106,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { int tDfn = 0, gDfn = 0; int pThread, cThread; int i; - int debuggee_thread_cnt = 0; + int threads_count = 0; NSK_DISPLAY0("Create threadList\n"); @@ -138,17 +138,17 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { continue; } - threadList[debuggee_thread_cnt].thread = threads[i]; - threadList[debuggee_thread_cnt].dfn = -1; - threadList[debuggee_thread_cnt].name = info.name; - debuggee_thread_cnt++; + threadList[debuggee_threads_cnt].thread = threads[i]; + threadList[debuggee_threads_cnt].dfn = -1; + threadList[debuggee_threads_cnt].name = info.name; + debuggee_threads_cnt++; } /* deallocate thread list */ if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) return NSK_FALSE; - for (i = 0; i < debuggee_thread_cnt; i++) { + for (i = 0; i < debuggee_threads_cnt; i++) { if (threadList[i].dfn < 0) { tDfn = gDfn; threadList[i].dfn = gDfn++; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp index 30511e0362d1d..88f4361dd60c3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp @@ -42,7 +42,7 @@ static jlong timeout = 0; /* test objects */ static threadDesc *threadList = nullptr; -static jint threads_count = 0; +static jint debuggee_threads_cnt = 0; static int numberOfDeadlocks = 0; static const char* THREAD_NAME_PREFIX = "Debugee Thread"; @@ -77,7 +77,7 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { return NSK_FALSE; if (usageInfo.owner == nullptr) break; - for (cThread = 0; cThread < threads_count; cThread++) { + for (cThread = 0; cThread < debuggee_threads_cnt; cThread++) { if (jni->IsSameObject(threadList[cThread].thread, usageInfo.owner)) break; } @@ -87,7 +87,7 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { if (usageInfo.notify_waiters != nullptr) { jvmti->Deallocate((unsigned char*)usageInfo.notify_waiters); } - if (!NSK_VERIFY(cThread != threads_count)) + if (!NSK_VERIFY(cThread != debuggee_threads_cnt)) return NSK_FALSE; NSK_DISPLAY1(" which is held by \"%s\"\n", threadList[cThread].name); @@ -106,7 +106,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { int tDfn = 0, gDfn = 0; int pThread, cThread; int i; - int debuggee_thread_cnt = 0; + int threads_count = 0; NSK_DISPLAY0("Create threadList\n"); @@ -138,17 +138,17 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { continue; } - threadList[debuggee_thread_cnt].thread = threads[i]; - threadList[debuggee_thread_cnt].dfn = -1; - threadList[debuggee_thread_cnt].name = info.name; - debuggee_thread_cnt++; + threadList[debuggee_threads_cnt].thread = threads[i]; + threadList[debuggee_threads_cnt].dfn = -1; + threadList[debuggee_threads_cnt].name = info.name; + debuggee_threads_cnt++; } /* deallocate thread list */ if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) return NSK_FALSE; - for (i = 0; i < debuggee_thread_cnt; i++) { + for (i = 0; i < debuggee_threads_cnt; i++) { if (threadList[i].dfn < 0) { tDfn = gDfn; From 954fc28059bf72ee26b72330ab3b4d8a17f1681a Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Thu, 16 Oct 2025 19:23:42 -0700 Subject: [PATCH 8/9] renamed threadList --- .../contention/TC03/tc03t001/tc03t001.cpp | 36 +++++++++---------- .../contention/TC03/tc03t002/tc03t002.cpp | 36 +++++++++---------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp index 1ea8d8e074aae..a0a6678423a4f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp @@ -41,7 +41,7 @@ typedef struct { static jlong timeout = 0; /* test objects */ -static threadDesc *threadList = nullptr; +static threadDesc *debuggee_threads = nullptr; static jint debuggee_threads_cnt = 0; static int numberOfDeadlocks = 0; @@ -59,9 +59,9 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { NSK_DISPLAY1("Found deadlock #%d:\n", numberOfDeadlocks); for (pThread = dThread;;pThread = cThread) { - NSK_DISPLAY1(" \"%s\":\n", threadList[pThread].name); + NSK_DISPLAY1(" \"%s\":\n", debuggee_threads[pThread].name); if (!NSK_JVMTI_VERIFY( - jvmti->GetCurrentContendedMonitor(threadList[pThread].thread, &monitor))) + jvmti->GetCurrentContendedMonitor(debuggee_threads[pThread].thread, &monitor))) return NSK_FALSE; if (monitor != nullptr) { if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(monitor)) != nullptr)) @@ -78,7 +78,7 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { if (usageInfo.owner == nullptr) break; for (cThread = 0; cThread < debuggee_threads_cnt; cThread++) { - if (jni->IsSameObject(threadList[cThread].thread, usageInfo.owner)) + if (jni->IsSameObject(debuggee_threads[cThread].thread, usageInfo.owner)) break; } if (usageInfo.waiters != nullptr) { @@ -90,7 +90,7 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { if (!NSK_VERIFY(cThread != debuggee_threads_cnt)) return NSK_FALSE; NSK_DISPLAY1(" which is held by \"%s\"\n", - threadList[cThread].name); + debuggee_threads[cThread].name); if (cThread == dThread) break; } @@ -108,7 +108,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { int i; int threads_count = 0; - NSK_DISPLAY0("Create threadList\n"); + NSK_DISPLAY0("Create debuggee_threads\n"); /* get all live threads */ if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) @@ -118,7 +118,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_FALSE; if (!NSK_JVMTI_VERIFY( - jvmti->Allocate(threads_count*sizeof(threadDesc), (unsigned char**)&threadList))) + jvmti->Allocate(threads_count*sizeof(threadDesc), (unsigned char**)&debuggee_threads))) return NSK_FALSE; for (i = 0; i < threads_count; i++) { @@ -138,9 +138,9 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { continue; } - threadList[debuggee_threads_cnt].thread = threads[i]; - threadList[debuggee_threads_cnt].dfn = -1; - threadList[debuggee_threads_cnt].name = info.name; + debuggee_threads[debuggee_threads_cnt].thread = threads[i]; + debuggee_threads[debuggee_threads_cnt].dfn = -1; + debuggee_threads[debuggee_threads_cnt].name = info.name; debuggee_threads_cnt++; } @@ -149,12 +149,12 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_FALSE; for (i = 0; i < debuggee_threads_cnt; i++) { - if (threadList[i].dfn < 0) { + if (debuggee_threads[i].dfn < 0) { tDfn = gDfn; - threadList[i].dfn = gDfn++; + debuggee_threads[i].dfn = gDfn++; for (pThread = i;;pThread = cThread) { if (!NSK_JVMTI_VERIFY( - jvmti->GetCurrentContendedMonitor(threadList[pThread].thread, &monitor))) + jvmti->GetCurrentContendedMonitor(debuggee_threads[pThread].thread, &monitor))) return NSK_FALSE; if (monitor == nullptr) break; @@ -163,7 +163,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { if (usageInfo.owner == nullptr) break; for (cThread = 0; cThread < threads_count; cThread++) { - if (jni->IsSameObject(threadList[cThread].thread, usageInfo.owner)) + if (jni->IsSameObject(debuggee_threads[cThread].thread, usageInfo.owner)) break; } if (usageInfo.waiters != nullptr) { @@ -174,8 +174,8 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { } if (!NSK_VERIFY(cThread != threads_count)) return NSK_FALSE; - if (threadList[cThread].dfn < 0) { - threadList[cThread].dfn = gDfn++; + if (debuggee_threads[cThread].dfn < 0) { + debuggee_threads[cThread].dfn = gDfn++; } else if (cThread == pThread) { break; } else { @@ -192,8 +192,8 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { /* deallocate thread names */ for (i = 0; i < threads_count; i++) { - if (threadList[i].name != nullptr) { - if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threadList[i].name))) + if (debuggee_threads[i].name != nullptr) { + if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)debuggee_threads[i].name))) return NSK_FALSE; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp index 88f4361dd60c3..6bd1cc2191c98 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp @@ -41,7 +41,7 @@ typedef struct { static jlong timeout = 0; /* test objects */ -static threadDesc *threadList = nullptr; +static threadDesc *debuggee_threads = nullptr; static jint debuggee_threads_cnt = 0; static int numberOfDeadlocks = 0; @@ -59,9 +59,9 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { NSK_DISPLAY1("Found deadlock #%d:\n", numberOfDeadlocks); for (pThread = dThread;;pThread = cThread) { - NSK_DISPLAY1(" \"%s\":\n", threadList[pThread].name); + NSK_DISPLAY1(" \"%s\":\n", debuggee_threads[pThread].name); if (!NSK_JVMTI_VERIFY( - jvmti->GetCurrentContendedMonitor(threadList[pThread].thread, &monitor))) + jvmti->GetCurrentContendedMonitor(debuggee_threads[pThread].thread, &monitor))) return NSK_FALSE; if (monitor != nullptr) { if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(monitor)) != nullptr)) @@ -78,7 +78,7 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { if (usageInfo.owner == nullptr) break; for (cThread = 0; cThread < debuggee_threads_cnt; cThread++) { - if (jni->IsSameObject(threadList[cThread].thread, usageInfo.owner)) + if (jni->IsSameObject(debuggee_threads[cThread].thread, usageInfo.owner)) break; } if (usageInfo.waiters != nullptr) { @@ -90,7 +90,7 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { if (!NSK_VERIFY(cThread != debuggee_threads_cnt)) return NSK_FALSE; NSK_DISPLAY1(" which is held by \"%s\"\n", - threadList[cThread].name); + debuggee_threads[cThread].name); if (cThread == dThread) break; } @@ -108,7 +108,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { int i; int threads_count = 0; - NSK_DISPLAY0("Create threadList\n"); + NSK_DISPLAY0("Create debuggee_threads\n"); /* get all live threads */ if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) @@ -118,7 +118,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_FALSE; if (!NSK_JVMTI_VERIFY( - jvmti->Allocate(threads_count*sizeof(threadDesc), (unsigned char**)&threadList))) + jvmti->Allocate(threads_count*sizeof(threadDesc), (unsigned char**)&debuggee_threads))) return NSK_FALSE; for (i = 0; i < threads_count; i++) { @@ -138,9 +138,9 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { continue; } - threadList[debuggee_threads_cnt].thread = threads[i]; - threadList[debuggee_threads_cnt].dfn = -1; - threadList[debuggee_threads_cnt].name = info.name; + debuggee_threads[debuggee_threads_cnt].thread = threads[i]; + debuggee_threads[debuggee_threads_cnt].dfn = -1; + debuggee_threads[debuggee_threads_cnt].name = info.name; debuggee_threads_cnt++; } @@ -150,12 +150,12 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { for (i = 0; i < debuggee_threads_cnt; i++) { - if (threadList[i].dfn < 0) { + if (debuggee_threads[i].dfn < 0) { tDfn = gDfn; - threadList[i].dfn = gDfn++; + debuggee_threads[i].dfn = gDfn++; for (pThread = i;;pThread = cThread) { if (!NSK_JVMTI_VERIFY( - jvmti->GetCurrentContendedMonitor(threadList[pThread].thread, &monitor))) + jvmti->GetCurrentContendedMonitor(debuggee_threads[pThread].thread, &monitor))) return NSK_FALSE; if (monitor == nullptr) break; @@ -164,7 +164,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { if (usageInfo.owner == nullptr) break; for (cThread = 0; cThread < threads_count; cThread++) { - if (jni->IsSameObject(threadList[cThread].thread, usageInfo.owner)) + if (jni->IsSameObject(debuggee_threads[cThread].thread, usageInfo.owner)) break; } if (usageInfo.waiters != nullptr) { @@ -175,8 +175,8 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { } if (!NSK_VERIFY(cThread != threads_count)) return NSK_FALSE; - if (threadList[cThread].dfn < 0) { - threadList[cThread].dfn = gDfn++; + if (debuggee_threads[cThread].dfn < 0) { + debuggee_threads[cThread].dfn = gDfn++; } else if (cThread == pThread) { break; } else { @@ -193,8 +193,8 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { /* deallocate thread names */ for (i = 0; i < threads_count; i++) { - if (threadList[i].name != nullptr) { - if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threadList[i].name))) + if (debuggee_threads[i].name != nullptr) { + if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)debuggee_threads[i].name))) return NSK_FALSE; } } From 507b7e1812c33809bbed5732915524b72f94750a Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Fri, 17 Oct 2025 12:41:08 -0700 Subject: [PATCH 9/9] Apply suggestions from code review Co-authored-by: Alex Menkov --- .../jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp | 6 +++--- .../jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp index a0a6678423a4f..9ea61a27bc650 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp @@ -162,7 +162,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_FALSE; if (usageInfo.owner == nullptr) break; - for (cThread = 0; cThread < threads_count; cThread++) { + for (cThread = 0; cThread < debuggee_threads_cnt; cThread++) { if (jni->IsSameObject(debuggee_threads[cThread].thread, usageInfo.owner)) break; } @@ -172,7 +172,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { if (usageInfo.notify_waiters != nullptr) { jvmti->Deallocate((unsigned char*)usageInfo.notify_waiters); } - if (!NSK_VERIFY(cThread != threads_count)) + if (!NSK_VERIFY(cThread != debuggee_threads_cnt)) return NSK_FALSE; if (debuggee_threads[cThread].dfn < 0) { debuggee_threads[cThread].dfn = gDfn++; @@ -191,7 +191,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { } /* deallocate thread names */ - for (i = 0; i < threads_count; i++) { + for (i = 0; i < debuggee_threads_cnt; i++) { if (debuggee_threads[i].name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)debuggee_threads[i].name))) return NSK_FALSE; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp index 6bd1cc2191c98..5d18d6c23afdb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp @@ -163,7 +163,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_FALSE; if (usageInfo.owner == nullptr) break; - for (cThread = 0; cThread < threads_count; cThread++) { + for (cThread = 0; cThread < debuggee_threads_cnt; cThread++) { if (jni->IsSameObject(debuggee_threads[cThread].thread, usageInfo.owner)) break; } @@ -173,7 +173,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { if (usageInfo.notify_waiters != nullptr) { jvmti->Deallocate((unsigned char*)usageInfo.notify_waiters); } - if (!NSK_VERIFY(cThread != threads_count)) + if (!NSK_VERIFY(cThread != debuggee_threads_cnt)) return NSK_FALSE; if (debuggee_threads[cThread].dfn < 0) { debuggee_threads[cThread].dfn = gDfn++; @@ -192,7 +192,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { } /* deallocate thread names */ - for (i = 0; i < threads_count; i++) { + for (i = 0; i < debuggee_threads_cnt; i++) { if (debuggee_threads[i].name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)debuggee_threads[i].name))) return NSK_FALSE;