Attempt to avoid an exception I caught once in gdb, trying to debug msys2/MSYS2-packages#2752. Unfortunately I haven't been able to catch it in the act again since, but with this change running on Windows on ARM64 has been more reliable than it had been. --- winsup/cygwin/fhandler_pipe.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/fhandler_pipe.cc b/winsup/cygwin/fhandler_pipe.cc index ba6b70f55..48713a38d 100644 --- a/winsup/cygwin/fhandler_pipe.cc +++ b/winsup/cygwin/fhandler_pipe.cc @@ -1239,7 +1239,7 @@ fhandler_pipe::get_query_hdl_per_process (WCHAR *name, if (!NT_SUCCESS (status)) goto close_proc; - for (ULONG j = 0; j < phi->NumberOfHandles; j++) + for (ULONG j = 0; j < min(phi->NumberOfHandles, n_handle); j++) { /* Check for the peculiarity of cygwin read pipe */ const ULONG access = FILE_READ_DATA | FILE_READ_EA @@ -1309,7 +1309,7 @@ fhandler_pipe::get_query_hdl_per_system (WCHAR *name, if (!NT_SUCCESS (status)) return NULL; - for (LONG i = (LONG) shi->NumberOfHandles - 1; i >= 0; i--) + for (LONG i = (LONG) min(shi->NumberOfHandles, n_handle) - 1; i >= 0; i--) { /* Check for the peculiarity of cygwin read pipe */ const ULONG access = FILE_READ_DATA | FILE_READ_EA -- 2.34.1.windows.1