Skip to content
Permalink
Browse files
8264605: vmTestbase/nsk/jvmti/SuspendThread/suspendthrd003/TestDescri…
…ption.java failed with "agent_tools.cpp, 471: (foundThread = (jthread) jni_env->NewGlobalRef(foundThread)) != NULL"

Backport-of: 96fe1d0d4d95d87950ff2ecec570a927d831746e
  • Loading branch information
TheRealMDoerr committed Mar 30, 2022
1 parent 373526a commit 0200d64ee32ad7f46db400b754bd2492bdd96876
Showing 2 changed files with 12 additions and 22 deletions.
@@ -154,7 +154,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/nsk/jvmti/PopFrame/popframe011/TestDescription.java 8266593 generic-all

vmTestbase/gc/lock/jni/jnilock002/TestDescription.java 8192647 generic-all
@@ -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
@@ -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. */

1 comment on commit 0200d64

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 0200d64 Mar 30, 2022

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.