[newlib-cygwin] Cygwin: Don't increment DLL reference count in dladdr.

Jeremy Drake via Cygwin-cvs <[email protected]>
Newsgroups gmane.os.cygwin.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=97f9ef33704a109b7a48bffacfdb03e47dce9cf5

commit 97f9ef33704a109b7a48bffacfdb03e47dce9cf5
Author: Jeremy Drake <[email protected]>
Date:   Sat Apr 5 10:17:40 2025 -0700

    Cygwin: Don't increment DLL reference count in dladdr.
    
    Unlike GetModuleHandle, GetModuleHandleEx increments the reference count
    by default unless the GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT flag
    is passed.
    
    Fixes: c8432a01c840 ("Implement dladdr() (partially)")
    Addresses: https://cygwin.com/pipermail/cygwin/2025-April/257864.html
    Signed-off-by: Jeremy Drake <[email protected]>

Diff:
---
 winsup/cygwin/dlfcn.cc      | 3 ++-
 winsup/cygwin/release/3.6.1 | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc
index f029ebbf2..10bd0ac1f 100644
--- a/winsup/cygwin/dlfcn.cc
+++ b/winsup/cygwin/dlfcn.cc
@@ -408,7 +408,8 @@ extern "C" int
 dladdr (const void *addr, Dl_info *info)
 {
   HMODULE hModule;
-  BOOL ret = GetModuleHandleEx (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+  BOOL ret = GetModuleHandleEx (GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT|
+				GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
 				(LPCSTR) addr,
 				&hModule);
   if (!ret)
diff --git a/winsup/cygwin/release/3.6.1 b/winsup/cygwin/release/3.6.1
index c09a23376..280952c91 100644
--- a/winsup/cygwin/release/3.6.1
+++ b/winsup/cygwin/release/3.6.1
@@ -36,3 +36,6 @@ Fixes:
   subprocess failure in cmake (>= 3.29.x).
   Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257800.html
   Addresses: https://github.com/msys2/msys2-runtime/issues/272
+
+- Don't increment DLL reference count in dladdr.
+  Addresses: https://cygwin.com/pipermail/cygwin/2025-April/257862.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.