https://bugs.openjdk.org/browse/JDK-8352180 added a ThreadBlockInVM in `PipeChannel::close()`, which in turn is called from the PipeChannel destructor. We may delete a `Win32AttachOperation` and call this destructor from Win32AttachListener::dequeue() with an open pipe. And as the thread is already block at this point, we will try to enter blocked from blocked.
```
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (runtime/interfaceSupport.inline.hpp:111), pid=10844, tid=2304
# assert(thread->thread_state() == _thread_in_vm) failed: coming from wrong thread state
#
# JRE version: Java(TM) SE Runtime Environment (25.0) (fastdebug build 25-internal-LTS-2025-05-05-0743130.axel.boldt-christmas.zgc)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 25-internal-LTS-2025-05-05-0743130.axel.boldt-christmas.zgc, compiled mode, compressed class ptrs, z gc, windows-amd64)
# Problematic frame:
# V [jvm.dll+0x38716b] ThreadBlockInVM::ThreadBlockInVM+0xfb
#
--------------- T H R E A D ---------------
Current thread (0x00000229e12a06d0): JavaThread "Attach Listener" daemon [_thread_blocked, id=2304, stack(0x0000009641e00000,0x0000009641f00000) (1024K)]
Stack: [0x0000009641e00000,0x0000009641f00000], sp=0x0000009641eff9a0, free space=1022k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0x38716b] ThreadBlockInVM::ThreadBlockInVM+0xfb (interfaceSupport.inline.hpp:226)
V [jvm.dll+0x387480] PipeChannel::~PipeChannel+0x40 (attachListener_windows.cpp:70)
V [jvm.dll+0x38751c] Win32AttachOperation::`scalar deleting destructor'+0x1c (no source info available)
V [jvm.dll+0x387803] Win32AttachListener::dequeue+0x1e3 (attachListener_windows.cpp:417)
V [jvm.dll+0x3875dc] AttachListener::dequeue+0x3c (attachListener_windows.cpp:449)
V [jvm.dll+0x386cb6] AttachListenerThread::thread_entry+0x4d6 (attachListener.cpp:607)
V [jvm.dll+0x918188] JavaThread::thread_main_inner+0x288 (javaThread.cpp:774)
V [jvm.dll+0x1001e02] Thread::call_run+0x1b2 (thread.cpp:236)
V [jvm.dll+0xdc2891] thread_native_entry+0xe1 (os_windows.cpp:564)
C [ucrtbase.dll+0x26b4c] (no source info available)
C [KERNEL32.DLL+0x14cb0] (no source info available)
C [ntdll.dll+0x7edcb] (no source info available)
```
```
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (runtime/interfaceSupport.inline.hpp:111), pid=10844, tid=2304
# assert(thread->thread_state() == _thread_in_vm) failed: coming from wrong thread state
#
# JRE version: Java(TM) SE Runtime Environment (25.0) (fastdebug build 25-internal-LTS-2025-05-05-0743130.axel.boldt-christmas.zgc)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 25-internal-LTS-2025-05-05-0743130.axel.boldt-christmas.zgc, compiled mode, compressed class ptrs, z gc, windows-amd64)
# Problematic frame:
# V [jvm.dll+0x38716b] ThreadBlockInVM::ThreadBlockInVM+0xfb
#
--------------- T H R E A D ---------------
Current thread (0x00000229e12a06d0): JavaThread "Attach Listener" daemon [_thread_blocked, id=2304, stack(0x0000009641e00000,0x0000009641f00000) (1024K)]
Stack: [0x0000009641e00000,0x0000009641f00000], sp=0x0000009641eff9a0, free space=1022k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0x38716b] ThreadBlockInVM::ThreadBlockInVM+0xfb (interfaceSupport.inline.hpp:226)
V [jvm.dll+0x387480] PipeChannel::~PipeChannel+0x40 (attachListener_windows.cpp:70)
V [jvm.dll+0x38751c] Win32AttachOperation::`scalar deleting destructor'+0x1c (no source info available)
V [jvm.dll+0x387803] Win32AttachListener::dequeue+0x1e3 (attachListener_windows.cpp:417)
V [jvm.dll+0x3875dc] AttachListener::dequeue+0x3c (attachListener_windows.cpp:449)
V [jvm.dll+0x386cb6] AttachListenerThread::thread_entry+0x4d6 (attachListener.cpp:607)
V [jvm.dll+0x918188] JavaThread::thread_main_inner+0x288 (javaThread.cpp:774)
V [jvm.dll+0x1001e02] Thread::call_run+0x1b2 (thread.cpp:236)
V [jvm.dll+0xdc2891] thread_native_entry+0xe1 (os_windows.cpp:564)
C [ucrtbase.dll+0x26b4c] (no source info available)
C [KERNEL32.DLL+0x14cb0] (no source info available)
C [ntdll.dll+0x7edcb] (no source info available)
```
- caused by
-
JDK-8352180 AttachListenerThread causes many tests to timeout on Windows
-
- Resolved
-