Skip to content

Commit

Permalink
Return NULL from getStackTraceForThread for unsteady virtual threads
Browse files Browse the repository at this point in the history
If inspectorCount is -1, then the virtual thread is in an unsteady
state (mounting or unmounting). In such cases, NULL should be returned
and the JCL code should retry in order to avoid unexpected behavior.

Related: eclipse-openj9#18910

Signed-off-by: Babneet Singh <[email protected]>
  • Loading branch information
babsingh authored and zl-wang committed Nov 8, 2024
1 parent 14b5454 commit 7daceba
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion runtime/jcl/common/getstacktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,16 @@ getStackTraceForThread(J9VMThread *currentThread, J9VMThread *targetThread, UDAT
*/
walkState.skipCount = 0;
rc = vmfns->walkContinuationStackFrames(currentThread, targetThread->currentContinuation, threadObject, &walkState);
} else if (isVirtual && (threadObject != targetThread->threadObject)) {
} else if (isVirtual
&& ((threadObject != targetThread->threadObject)
|| (-1 == J9OBJECT_I64_LOAD(currentThread, threadObject, vm->virtualThreadInspectorCountOffset)))
) {
/* If the virtual thread object doesn't match the current thread object, it must have unmounted
* from this carrier thread, return NULL and the JCL code will handle the retry.
*
* If inspectorCount is -1, then the virtual thread is in an unsteady state (mounting or unmounting).
* In such cases, NULL should be returned and the JCL code should retry in order to avoid unexpected
* behavior.
*/
vmfns->resumeThreadForInspection(currentThread, targetThread);
goto done;
Expand Down

0 comments on commit 7daceba

Please sign in to comment.