Due to being converted to a mbcs, the output of converting a wide string of MAX_PATH characters is potentially larger than MAX_PATH bytes. The DL_info::dli_fname member is actually PATH_MAX bytes, so specify that (larger) size to cygwin_conv_path rather than PATH_MAX.
Fixes: c8432a01c840 ("Implement dladdr() (partially)") Addresses: https://github.com/rust-lang/backtrace-rs/pull/704#issuecomment-2833782574 Signed-off-by: Jeremy Drake <cyg...@jdrake.com> --- Would it be better to use tmp_pathbuf in place of the fname WCHAR array, to allow longer paths to come out of GetModuleFileNameW? winsup/cygwin/dlfcn.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc index 10bd0ac1f4..a3523b6153 100644 --- a/winsup/cygwin/dlfcn.cc +++ b/winsup/cygwin/dlfcn.cc @@ -428,7 +428,7 @@ dladdr (const void *addr, Dl_info *info) /* Convert to a cygwin pathname */ ssize_t conv = cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_ABSOLUTE, fname, - info->dli_fname, MAX_PATH); + info->dli_fname, PATH_MAX); if (conv) return 0; -- 2.49.0.windows.1