Skip to content

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 a case because we never check the return value of the 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. The BIND 9 doesn't create/destroy threads for it to make actually any difference and we in fact use statict thread local storage in the code.

Closes #2519 (closed)

Merge request reports