RFR: 8299414: JVMTI FollowReferences should support references from VirtualThread stack [v5]

Alex Menkov amenkov at openjdk.org
Tue Apr 11 18:56:37 UTC 2023


On Tue, 11 Apr 2023 03:07:04 GMT, David Holmes <dholmes at openjdk.org> wrote:

> Seems to me the bug report is asking for unmounted virtual threads to be considered roots - but virtual threads are deliberately not roots. Any unmounted virtual thread should be reachable from either the scheduler or whatever object the VT is parked on, so if they are not showing up then perhaps the wrong reference is being followed. If there is a bug/missing-functionality in the FollowReferences implementation then fixing it is of course fine, but that is not what the bug report seems to be about. ???

The bug is about objects referenced only from stack of unmounted VT are not reported by FollowReferences.
So we need to detect stackChunk object and report references from them.
Next question - how to report them (jvmtiHeapReferenceKind).
Stack locals for java threads are reported as JVMTI_HEAP_REFERENCE_STACK_LOCAL and this looks appropriate kind for this references.
For JVMTI_HEAP_REFERENCE_STACK_LOCAL kind reference_info should contain pointer to jvmtiHeapReferenceInfoStackLocal structure, which contain info about thread (thread_tag, thread_id).
It would be strange if we report stack locals from a thread without reporting thread itself (reference with JVMTI_HEAP_REFERENCE_THREAD kind), so we need to detect corresponding VirtualThread and report it.
So we implicitly consider VT and their stack locals as roots and this made me think we need to report all of them.
But as you mentioned VTs are deliberately not roots, so maybe we don't need to detect all of them and reporting only objects we found by following references is enough.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/13254#issuecomment-1503929711


More information about the serviceability-dev mailing list