https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d77cb8e350346a060bb6ce722b93851f5b5f8bd3

commit d77cb8e350346a060bb6ce722b93851f5b5f8bd3
Author: Takashi Yano <[email protected]>
Date:   Tue Oct 28 09:47:10 2025 +0900

    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: 2eb392bd77de ("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]>

Diff:
---
 winsup/cygwin/dll_init.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc
index d2ed74bed..6fae8f145 100644
--- a/winsup/cygwin/dll_init.cc
+++ b/winsup/cygwin/dll_init.cc
@@ -618,9 +618,10 @@ dll_list::init ()
   /* Walk the dll chain, initializing each dll */
   dll *d = &start;
   dll_global_dtors_recorded = d->next != NULL;
-  /* Init linked and early loaded Cygwin DLLs. */
+  /* Init linked Cygwin DLLs. As for loaded DLLs, dll::init() is already
+     called via _cygwin_dll_entry called from LoadLibrary(). */
   while ((d = d->next))
-    if (d->type == DLL_LINK || d->type == DLL_LOAD)
+    if (d->type == DLL_LINK)
       d->init ();
 }

Reply via email to