Encountered this issue during the use followReferences() to traverse the heap.
Under Heap_Reference_Callback of followReferences
Reference kind JVMTI_HEAP_REFERENCE_STACK_LOCAL callbacks come back with frame numbers one less than the number of frames in the thread traces.
So if we get the stack trace for a thread and it has 12 frames.
The callbacks from JVMTI_HEAP_REFERENCE_STACK_LOCAL come back with stack_local.depth from 1 through 11 for the same thread.
Also for reference kind JVMTI_HEAP_REFERENCE_JNI_LOCAL callbacks the frame number i.e. reference_info->jni_local.depth is always 0.
Is a frame number 0 valid?
In profiling with JVMPI interface-
The record type JVMPI_GC_ROOT_JAVA_FRAME has the correct number of frames that correspond with the number of thread traces for each thread.
And record type JVMPI_GC_ROOT_JNI_LOCAL has frame numbers.
Wanted to know if the other users obtained
1) better results with no issues for Heap_Reference_Callbacks or
2) similar results i.e. mismatch between number of frames in thread trace and JVMTI_HEAP_REFERENCE_STACK_LOCAL frame numbers and other issue with frame number = 0 for JVMTI_HEAP_REFERENCE_JNI_LOCAL.
Thanks in advance for sharing your experience.