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 <noreply@anthropic.com>
This commit is contained in:
Adrià Franch 2026-10-13 15:05:30 +02:00
parent 90c64af925
commit 9c383e3295
2 changed files with 3 additions and 8 deletions

View File

@ -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(); }

View File

@ -57,9 +57,6 @@ int main() {
}
void* directDso = module;
#ifdef _WIN32
directDso = nullptr;
#endif
int firstObject = 1;
int secondObject = 2;