Skip to content

Commit

Permalink
Fix BoundVThreadTest - Bad Thread Object
Browse files Browse the repository at this point in the history
After GetAllStackTraces, derive the thread object from the
stack_info array, which is filled by GetAllStackTraces.

Currently, the thread object is retrieved from the threads_ptr
array, which is filled by GetAllThreads before the call to
GetAllStackTraces. Live platform threads might have been created
or destroyed between the call to GetAllThreads and GetAllStackTraces.
This makes the threads_ptr array stale after GetAllStackTraces. A bad
thread object is accessed from the stale threads_ptr which causes a
segfault.

Related: eclipse-openj9/openj9#17868

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
  • Loading branch information
babsingh committed Aug 3, 2023
1 parent de66741 commit d867a25
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

#include <string.h>
#include "jvmti.h"
#include "jvmti_common.h"
Expand Down Expand Up @@ -137,8 +143,8 @@ test_unsupported_jvmti_functions(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread,
err = jvmti->GetAllStackTraces(MAX_FRAMES, &stack_info, &thread_cnt);
check_jvmti_status(jni, err, "test_unsupported_jvmti_functions: error in JVMTI GetAllStackTraces");
for (int idx = 0; idx < thread_cnt; idx++) {
jthread thread = threads_ptr[idx];
if (jni->IsVirtualThread(thread)) {
jvmtiStackInfo *info = &stack_info[idx];
if (jni->IsVirtualThread(info->thread)) {
fatal(jni, "GetAllStackTraces should not include virtual threads");
}
}
Expand Down

0 comments on commit d867a25

Please sign in to comment.