On Thu, 13 Jul 2023 19:18:38 GMT, Alex Menkov <amen...@openjdk.org> wrote:
> The change fixes handling of "suspended" bit in VT state. > The code looks very strange. > java_lang_VirtualThread::RUNNING == 3, so line 803 clears > JVMTI_THREAD_STATE_ALIVE(1) and JVMTI_THREAD_STATE_TERMINATED(2) > Per log this code came from loom repo with VT integration. > > Testing: tier1-4, updated GetThreadStateMountedTest.java So AFAIU GetThreadState for platform threads (get_thread_state_base) don't have similar issue because suspended/interrupted values are read after reading main thread state value. For virtual threads suspended/interrupted values are read before. There is a comment in the line 796: `// This call can trigger a safepoint, so thread_oop must not be used after it.` I suppose this is the reason to read them earlier. Then I think we need to ensure the thread is still alive before applying suspended/interrupted bits ------------- PR Comment: https://git.openjdk.org/jdk/pull/14878#issuecomment-1638975987