You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unit tests on Windows with DEBUG_LOCKORDER have been broken for a while #36973
I was testing some socket stuff in a Windows VM and noticed unit tests don't pass for a mingw build with -DCMAKE_BUILD_TYPE=Debug. The regression was introduced in #35614. To reproduce, build with DEBUG_LOCKORDER and run that HTTP server test:
Haven't looked into the bug myself, but apparently it's trivial to fix. See slop below.
LLM summary of the issue
In several socket paths, WSAGetLastError() is read after leaving the LOCK(m_sock_mutex) scope that wrapped the send()/recv() call. With DEBUG_LOCKORDER, releasing the lock runs pop_lock() (src/sync.cpp:212, :215), which calls std::this_thread::get_id(). With the mingw-w64 posix thread model, that call resets the Windows last error to 0. A WSAEWOULDBLOCK is then read as error 0, which IOErrorIsPermanent() treats as permanent, so the connection is dropped.
Suggested fix. Read WSAGetLastError() inside the lock scope, right after the socket call. With that change, the test passes on Windows Debug.
Confirmed the unit test failure locally and only with a cross-compiled debug build, so I have a baseline to review #37005
Sloppy explanation: clang-cl implements get_id() without touching the thread, but the posix model makes an extra call that succeeds, wiping the error value.
Activity
fanquake commentedon Nov 25, 2026
The fix here should also be backported to
32.x.pinheadmz commentedon Nov 30, 2026
Just double checking, your build was cross-compiled MinGW and not the (recently updated to) clang-cl on windows native?
darosior commentedon Nov 30, 2026
Windows: Add a GCC cross-build job with the "Debug" configuration
hebasto commentedon Nov 30, 2026
Unit tests on Windows with
DEBUG_LOCKORDERhave been reproduced here: hebasto/bitcoin-core-nightly#497.pinheadmz commentedon Nov 30, 2026
Confirmed the unit test failure locally and only with a cross-compiled debug build, so I have a baseline to review #37005
Sloppy explanation: clang-cl implements
get_id()without touching the thread, but the posix model makes an extra call that succeeds, wiping the error value.