Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass NULL walkState to jvmti callback for JNI local reference on stack #18394

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtime/gc_base/ReferenceChainWalker.cpp
Original file line number Diff line number Diff line change
@@ -646,7 +646,7 @@ MM_ReferenceChainWalker::doStackSlot(J9Object **slotPtr, void *walkState, const
/* Only report heap objects */
if (isHeapObject(slotValue) && !_heap->objectIsInGap(slotValue)) {
if (J9_STACKWALK_SLOT_TYPE_JNI_LOCAL == ((J9StackWalkState *)walkState)->slotType) {
doSlot(slotPtr, J9GC_ROOT_TYPE_JNI_LOCAL, -1, (J9Object *)walkState);
doSlot(slotPtr, J9GC_ROOT_TYPE_JNI_LOCAL, -1, NULL);
} else {
doSlot(slotPtr, J9GC_ROOT_TYPE_STACK_SLOT, -1, (J9Object *)walkState);
Comment on lines +649 to 651
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the cast was suspicious when I saw #18379, NULL seems more reasonable, but why should the call on line 651 not also pass NULL?

Copy link
Contributor

@amicic amicic Nov 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A valid question. In theory, callbacks being aware that the type is STACK_SLOT could safely cast the referrer parameter back to walkState type and do something about that info/structure (print stack slot address etc), but I don't know if they do.

I'm ok with passing NULL, but don't have the whole picture (history and awareness of current callbacks) to say it's really safe.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we pass NULL for STACK_SLOT, it will break the expectation in jvmtiHeap10.c::processStackRoot() function.

}