2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

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.
This commit is contained in:
Ondřej Surý 2021-02-24 06:55:36 +01:00
parent de00c105bb
commit c5887c4312

View File

@ -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: