From 9c383e329591f945e9985726cca80b71f2492b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Tue, 13 Oct 2026 15:05:30 +0200 Subject: [PATCH] fix(libc): ignore the guest DSO of thread atexit on Windows in the shared bridge MinGW's __cxa_thread_atexit asserts dso is null or its own __dso_handle, so every guest export that forwards a guest module pointer needs the null rule, not only LibcInternalExtCxaThreadAtexit. The test now passes a non-host DSO on Windows too. Co-Authored-By: Claude --- core/libs/prx/libc/src/CxxAbiSupport.cpp | 8 +++----- core/libs/tests/GuestThreadCallbackAbi.cpp | 3 --- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/core/libs/prx/libc/src/CxxAbiSupport.cpp b/core/libs/prx/libc/src/CxxAbiSupport.cpp index 27d7a47a5..2553a80f7 100644 --- a/core/libs/prx/libc/src/CxxAbiSupport.cpp +++ b/core/libs/prx/libc/src/CxxAbiSupport.cpp @@ -62,6 +62,9 @@ void* APS5_VABI __cxa_demangle_nid_postfix(const char* mangled, char* buf, std:: } int APS5_VABI __cxa_thread_atexit_impl_nid_postfix(void (APS5_VABI *func)(void*), void* arg, void* dso) { +#ifdef _WIN32 + dso = nullptr; +#endif struct ThreadAtexitContext { void (APS5_VABI *destructor)(void*); void* object; @@ -88,12 +91,7 @@ int APS5_VABI __cxa_thread_atexit_nid_postfix(void (APS5_VABI *func)(void*), voi } int APS5_VABI LibcInternalExtCxaThreadAtexit_nid_postfix(void (APS5_VABI *destructor)(void*), void* object, void* module_id) { -#ifdef _WIN32 - (void)module_id; - return __cxa_thread_atexit_impl_nid_postfix(destructor, object, nullptr); -#else return __cxa_thread_atexit_impl_nid_postfix(destructor, object, module_id); -#endif } const std::error_category* _ZSt17iostream_categoryv_nid_postfix() { return &std::iostream_category(); } diff --git a/core/libs/tests/GuestThreadCallbackAbi.cpp b/core/libs/tests/GuestThreadCallbackAbi.cpp index 3dde6e237..4fe7aa04c 100644 --- a/core/libs/tests/GuestThreadCallbackAbi.cpp +++ b/core/libs/tests/GuestThreadCallbackAbi.cpp @@ -57,9 +57,6 @@ int main() { } void* directDso = module; -#ifdef _WIN32 - directDso = nullptr; -#endif int firstObject = 1; int secondObject = 2;