Skip to content

Commit

Permalink
Merge pull request #18690 from babsingh/18688_042
Browse files Browse the repository at this point in the history
(0.42) Add a NULL check on threadObject in destroyThreadData
  • Loading branch information
gacholio authored Jan 5, 2024
2 parents 69b6ceb + 101e71e commit 874af12
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions runtime/jvmti/jvmtiHook.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,21 @@ static void
destroyThreadData(J9JVMTIEnv *j9env, J9VMThread *vmThread)
{
j9object_t threadObject = vmThread->threadObject;
if (NULL != threadObject) {
#if JAVA_SPEC_VERSION >= 19
void *tlsArray = J9OBJECT_ADDRESS_LOAD(vmThread, threadObject, vmThread->javaVM->tlsOffset);
void *tlsArray = J9OBJECT_ADDRESS_LOAD(vmThread, threadObject, vmThread->javaVM->tlsOffset);

if (NULL != tlsArray)
if (NULL != tlsArray)
#endif /* JAVA_SPEC_VERSION >= 19 */
{
/* Deallocate the thread data block for this environment/thread pair, if it exists. */
J9JVMTIThreadData *threadData = jvmtiTLSGet(vmThread, threadObject, j9env->tlsKey);
if (NULL != threadData) {
jvmtiTLSSet(vmThread, threadObject, j9env->tlsKey, NULL);
omrthread_monitor_enter(j9env->threadDataPoolMutex);
pool_removeElement(j9env->threadDataPool, threadData);
omrthread_monitor_exit(j9env->threadDataPoolMutex);
{
/* Deallocate the thread data block for this environment/thread pair, if it exists. */
J9JVMTIThreadData *threadData = jvmtiTLSGet(vmThread, threadObject, j9env->tlsKey);
if (NULL != threadData) {
jvmtiTLSSet(vmThread, threadObject, j9env->tlsKey, NULL);
omrthread_monitor_enter(j9env->threadDataPoolMutex);
pool_removeElement(j9env->threadDataPool, threadData);
omrthread_monitor_exit(j9env->threadDataPoolMutex);
}
}
}
}
Expand Down

0 comments on commit 874af12

Please sign in to comment.