From: Ondřej Surý Date: Wed, 24 Feb 2021 05:55:36 +0000 (+0100) Subject: Disable safe-guard assertion in DLL_THREAD_ATTACH/DLL_THREAD_DETACH X-Git-Tag: v9.17.11~27^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c5887c4312e67adb93c37964008d7d0bb477452f;p=thirdparty%2Fbind9.git 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. --- diff --git a/lib/isc/win32/DLLMain.c b/lib/isc/win32/DLLMain.c index c649effbc27..0ae51771987 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: