On Thu, 6 Apr 2023 18:53:59 GMT, Alan Bateman <al...@openjdk.org> wrote:

> FollowReferences is a graph walk so it will visit the reachable virtual 
> Threads. If I'm not mistake, VThreadClosure will iterate over unreachable 
> Virtual Thread objects. That might be okay as they should be terminated and 
> thus not have any frames, but maybe the other approach needs to be explored 
> too.

The fix is for the case when FollowReferences is called with null 
initial_object.
Per spec in the case "references are followed from the heap roots".
And: "The heap root are the set of system classes, JNI globals, references from 
thread stacks, and other objects used as roots for the purposes of garbage 
collection."

FollowReferences visits all reachable virtual threads only if agent callback 
always returns JVMTI_VISIT_OBJECTS.
If agent callback doesn't return JVMTI_VISIT_OBJECTS for some object, 
references from the object are not traversed, so some unmounted vthreads may be 
missed.

VThreadClosure iterates over all VirtualThread objects, but skips mounted and 
terminated threads.
After reporting the object is marked "visited" and won't be reported again when 
some objects have reference to it.

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

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

Reply via email to