Skip to content

Commit d77cb8e

Browse files
committed
Cygwin: dll_init: Don't call dll::init() twice for DLL_LOAD.
If dlopen() for DLL A is called in constructor DLL B, the constructor for DLL A is called twice, once called via cygwin_attach_dll() called from LoadLibrary(), and again from dll_list::init(). That is, the DLL with DLL_LOAD does not need dll::init() in dll_list::init(). This issue was found when debugging the issue: https://cygwin.com/pipermail/cygwin/2025-October/258877.html This patch remove dll::init() call in dll_list::init() for DLL_LOAD. Fixes: 2eb392b ("dll_init.cc: Revamp. Use new classes.") Reviewed-by: Mark Geisert <[email protected]>, Jon Turney <[email protected]>, Corinna Vinschen <[email protected]> Signed-off-by: Takashi Yano <[email protected]>
1 parent 0d2f981 commit d77cb8e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

winsup/cygwin/dll_init.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,10 @@ dll_list::init ()
618618
/* Walk the dll chain, initializing each dll */
619619
dll *d = &start;
620620
dll_global_dtors_recorded = d->next != NULL;
621-
/* Init linked and early loaded Cygwin DLLs. */
621+
/* Init linked Cygwin DLLs. As for loaded DLLs, dll::init() is already
622+
called via _cygwin_dll_entry called from LoadLibrary(). */
622623
while ((d = d->next))
623-
if (d->type == DLL_LINK || d->type == DLL_LOAD)
624+
if (d->type == DLL_LINK)
624625
d->init ();
625626
}
626627

0 commit comments

Comments
 (0)