From 479e4f763a47c9c7ac82b3cba744112a9a9a2329 Mon Sep 17 00:00:00 2001 From: hulin Date: Mon, 30 Oct 2023 17:13:41 -0400 Subject: [PATCH] Fix JNI Local Reference reporting issue JNI Local References could be found on the stack(first 8 of them) or from GC_VMThreadJNISlotIterator (vmThread->jniLocalReferences). need to update MM_ReferenceChainWalker::doVMThreadSlot() to report J9GC_ROOT_TYPE_JNI_LOCAL type for the case walkState->slotType = J9_STACKWALK_SLOT_TYPE_JNI_LOCAL. Signed-off-by: hulin --- runtime/gc_base/ReferenceChainWalker.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/runtime/gc_base/ReferenceChainWalker.cpp b/runtime/gc_base/ReferenceChainWalker.cpp index f1fae1cc55c..41e299fce16 100644 --- a/runtime/gc_base/ReferenceChainWalker.cpp +++ b/runtime/gc_base/ReferenceChainWalker.cpp @@ -644,9 +644,12 @@ MM_ReferenceChainWalker::doStackSlot(J9Object **slotPtr, void *walkState, const J9Object *slotValue = *slotPtr; /* Only report heap objects */ - if (isHeapObject(slotValue) && !_heap->objectIsInGap(slotValue)) { - doSlot(slotPtr, J9GC_ROOT_TYPE_STACK_SLOT, -1, (J9Object *)walkState); + if (J9_STACKWALK_SLOT_TYPE_JNI_LOCAL == ((J9StackWalkState *)walkState)->slotType) { + doSlot(slotPtr, J9GC_ROOT_TYPE_JNI_LOCAL, -1, (J9Object *)walkState); + } else { + doSlot(slotPtr, J9GC_ROOT_TYPE_STACK_SLOT, -1, (J9Object *)walkState); + } } }