From c5887c4312e67adb93c37964008d7d0bb477452f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 24 Feb 2021 06:55:36 +0100 Subject: [PATCH] Disable safe-guard assertion in DLL_THREAD_ATTACH/DLL_THREAD_DETACH The BIND 9 libraries on Windows define DllMain() optional entry point into a dynamic-link library (DLL). When the system starts or terminates a process or thread, it calls the entry-point function for each loaded DLL using the first thread of the process. When the DLL is being loaded into the virtual address space of the current process as a result of the process starting up, we make a call to DisableThreadLibraryCalls() which should disable the DLL_THREAD_ATTACH and DLL_THREAD_DETACH notifications for the specified dynamic-link library (DLL). This seems not be the case because we never check the return value of the DisableThreadLibraryCalls() call, and it could in fact fail. The DisableThreadLibraryCalls() function fails if the DLL specified by hModule has active static thread local storage, or if hModule is an invalid module handle. In this commit, we remove the safe-guard assertion put in place for the DLL_THREAD_ATTACH and DLL_THREAD_DETACH events and we just ignore them. BIND 9 doesn't create/destroy enough threads for it actually to make any difference, and in fact we do use static thread local storage in the code. --- lib/isc/win32/DLLMain.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/isc/win32/DLLMain.c b/lib/isc/win32/DLLMain.c index c649effbc2..0ae5177198 100644 --- a/lib/isc/win32/DLLMain.c +++ b/lib/isc/win32/DLLMain.c @@ -30,10 +30,6 @@ __declspec(dllexport) BOOL WINAPI * LoadLibrary. */ case DLL_PROCESS_ATTACH: - /* - * Disable DllMain() invocation on Thread creation/destruction - */ - DisableThreadLibraryCalls(hinstDLL); isc__mem_initialize(); isc__tls_initialize(); break; @@ -49,12 +45,6 @@ __declspec(dllexport) BOOL WINAPI case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: - /* - * Calling DllMain when attaching/detaching process has been - * disabled. - */ - INSIST(0); - ISC_UNREACHABLE(); break; default: