[PATCH] Cygwin: pipe: Give up to use query_hdl for non-cygwin apps.
Takashi Yano
takashi.yano@nifty.ne.jp
Sun Mar 3 05:09:07 GMT 2024
Non-cygwin app may call ReadFile() which makes NtQueryObject() for
ObjectNameInformation block in fhandler_pipe::get_query_hdl_per_process.
Therefore, stop to try to get query_hdl for non-cygwin apps.
Addresses: https://github.com/msys2/msys2-runtime/issues/202
Fixes: b531d6b06eeb ("Cygwin: pipe: Introduce temporary query_hdl.")
Reported-by: Alisa Sireneva, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Reviewed-by:
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
---
winsup/cygwin/fhandler/pipe.cc | 10 ++++++++++
winsup/cygwin/release/3.5.2 | 4 ++++
2 files changed, 14 insertions(+)
diff --git a/winsup/cygwin/fhandler/pipe.cc b/winsup/cygwin/fhandler/pipe.cc
index 1a97108b5..95c2f843a 100644
--- a/winsup/cygwin/fhandler/pipe.cc
+++ b/winsup/cygwin/fhandler/pipe.cc
@@ -1241,6 +1241,16 @@ fhandler_pipe::get_query_hdl_per_process (WCHAR *name,
for (LONG i = (LONG) n_process - 1; i >= 0; i--)
{
+ /* Non-cygwin app may call ReadFile() which makes NtQueryObject()
+ for ObjectNameInformation block. Therefore, stop to try to get
+ query_hdl for non-cygwin apps. */
+ pid_t cygpid;
+ if (!(cygpid = cygwin_pid (proc_pids[i])))
+ continue;
+ pinfo p (cygpid);
+ if (p && ISSTATE (p, PID_NOTCYGWIN))
+ continue;
+
HANDLE proc = OpenProcess (PROCESS_DUP_HANDLE
| PROCESS_QUERY_INFORMATION,
0, proc_pids[i]);
diff --git a/winsup/cygwin/release/3.5.2 b/winsup/cygwin/release/3.5.2
index 7d8df9489..efd30b64a 100644
--- a/winsup/cygwin/release/3.5.2
+++ b/winsup/cygwin/release/3.5.2
@@ -5,3 +5,7 @@ Fixes:
is already unmapped due to race condition. To avoid this issue,
shared console memory will be kept mapped if it belongs to CTTY.
Addresses: https://cygwin.com/pipermail/cygwin/2024-February/255561.html
+
+- Fix a problem that select() call for write-side of a pipe possibly
+ hangs with non-cygwin reader.
+ Addresses: https://github.com/msys2/msys2-runtime/issues/202
--
2.43.0
More information about the Cygwin-patches
mailing list