On Thu, 30 Nov 2023 05:29:46 GMT, Chris Plummer <cjplum...@openjdk.org> wrote:
> > There is a check for virtual thread liveness which has to be good enough in > > general: > > ``` > > 1617 static bool should_dump_vthread(oop vt) { > > 1618 return java_lang_VirtualThread::state(vt) != > > java_lang_VirtualThread::NEW > > 1619 && java_lang_VirtualThread::state(vt) != > > java_lang_VirtualThread::TERMINATED; > > 1620 } > > . . . > > 1919 if (java_lang_VirtualThread::is_instance(o) && > > ThreadDumper::should_dump_vthread(o)) { > > 1920 _vthread_dumper->dump_vthread(o, writer()); > > 1921 } > > ``` > > That should in general take care of most unreachable virtual threads, but > technically I don't think a virtual thread has to reach the TERMINATED state > in order to become unreachable. However, it will never get scheduled. I'm not sure I understand the scenario. The state is set to TERMINATED after the thread completes its execution. So a virtual thread was scheduled, mounted, did some work (as state != NEW) and then scheduler unmounts it and decides to not schedule it again and just "loses" it? This does not look like a real scenario for me, but anyway I think that's fine to report such unreachable virtual threads until GC collects the objects. ------------- PR Comment: https://git.openjdk.org/jdk/pull/16665#issuecomment-1834534568