Skip to content

Commit

Permalink
8264605: vmTestbase/nsk/jvmti/SuspendThread/suspendthrd003/TestDescri…
Browse files Browse the repository at this point in the history
…ption.java failed with "agent_tools.cpp, 471: (foundThread = (jthread) jni_env->NewGlobalRef(foundThread)) != NULL"

Reviewed-by: sspitsyn, dholmes
  • Loading branch information
lmesnik committed Nov 24, 2021
1 parent 077b2de commit 96fe1d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
1 change: 0 additions & 1 deletion test/hotspot/jtreg/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ vmTestbase/nsk/jvmti/AttachOnDemand/attach045/TestDescription.java 8202971 gener
vmTestbase/nsk/jvmti/scenarios/jni_interception/JI05/ji05t001/TestDescription.java 8219652 aix-ppc64
vmTestbase/nsk/jvmti/scenarios/jni_interception/JI06/ji06t001/TestDescription.java 8219652 aix-ppc64
vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab001/TestDescription.java 8219652 aix-ppc64
vmTestbase/nsk/jvmti/SuspendThread/suspendthrd003/TestDescription.java 8264605 generic-all

vmTestbase/gc/lock/jni/jnilock002/TestDescription.java 8192647 generic-all

Expand Down
33 changes: 12 additions & 21 deletions test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/agent_tools.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, 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
Expand Down Expand Up @@ -138,34 +138,25 @@ jvmtiEnv* nsk_jvmti_getAgentJVMTIEnv() {
return jvmti_env;
}

/* ============================================================================= */
static void set_agent_thread_state(thread_state_t value) {
rawMonitorEnter(jvmti_env, agent_data.monitor);
agent_data.thread_state = value;
rawMonitorNotify(jvmti_env, agent_data.monitor);
rawMonitorExit(jvmti_env, agent_data.monitor);
}

/** Wrapper for user agent thread. */
static void JNICALL
agentThreadWrapper(jvmtiEnv* jvmti_env, JNIEnv* agentJNI, void* arg) {
jni_env = agentJNI;

/* run user agent proc */
{
set_agent_thread_state(RUNNABLE);
rawMonitorEnter(jvmti_env, agent_data.monitor);
agent_data.thread_state = RUNNABLE;
rawMonitorNotify(jvmti_env, agent_data.monitor);
rawMonitorExit(jvmti_env, agent_data.monitor);

NSK_TRACE((*agentThreadProc)(jvmti_env, agentJNI, agentThreadArg));
NSK_TRACE((*agentThreadProc)(jvmti_env, agentJNI, agentThreadArg));

set_agent_thread_state(TERMINATED);
}
rawMonitorEnter(jvmti_env, agent_data.monitor);
agent_data.thread_state = TERMINATED;
agentJNI->DeleteGlobalRef(agentThread);
agentThread = NULL;
rawMonitorNotify(jvmti_env, agent_data.monitor);
rawMonitorExit(jvmti_env, agent_data.monitor);

/* finalize agent thread */
{
/* gelete global ref for agent thread */
agentJNI->DeleteGlobalRef(agentThread);
agentThread = NULL;
}
}

/** Start wrapper for user agent thread. */
Expand Down

1 comment on commit 96fe1d0

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.