On 07/04/2025 18:22, Jeremy Drake via Cygwin-patches wrote:
On Sat, 5 Apr 2025, Jeremy Drake via Cygwin-patches wrote:
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 <cyg...@jdrake.com>
---
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 f029ebbf2c..10bd0ac1f4 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 c09a23376e..280952c91a 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
Is this OK for me to push (to main and cygwin-3_6-branch)?
Yes, please go ahead.