forked from msys2/MSYS2-packages
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from git-for-windows/msys2-runtime-4eb0db9844…
…3ea3a75714d1046d775fa054b15045 msys2-runtime: update to 4eb0db98443ea3a75714d1046d775fa054b15045
- Loading branch information
Showing
7 changed files
with
410 additions
and
6 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
msys2-runtime/0075-pathconv-don-t-skip-arguments-with-double-quote.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
From 7793231f24aa7060214862852c09c7eb9c3cbdd2 Mon Sep 17 00:00:00 2001 | ||
From: Christoph Reiter <[email protected]> | ||
Date: Sat, 10 Feb 2024 08:31:55 +0100 | ||
Subject: [PATCH 75/N] pathconv: don't skip arguments with double quote | ||
|
||
It is used to pass strings/paths to the preprocessor and breaks | ||
for example the CPython build. For example -DPREFIX='"/ucrt64"'. | ||
|
||
Fixes msys2/msys2-runtime/#190 | ||
|
||
Signed-off-by: Johannes Schindelin <[email protected]> | ||
--- | ||
winsup/cygwin/msys2_path_conv.cc | 1 - | ||
1 file changed, 1 deletion(-) | ||
|
||
diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc | ||
index 133939a..1c60bf3 100644 | ||
--- a/winsup/cygwin/msys2_path_conv.cc | ||
+++ b/winsup/cygwin/msys2_path_conv.cc | ||
@@ -366,7 +366,6 @@ skip_p2w: | ||
switch (*it) { | ||
case '`': | ||
case '\'': | ||
- case '"': | ||
case '*': | ||
case '?': | ||
case '[': |
44 changes: 44 additions & 0 deletions
44
msys2-runtime/0076-Cygwin-console-Fix-exit-code-for-non-cygwin-process.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
From fdc7c9a039aab6001d74e9463decd45710d6798f Mon Sep 17 00:00:00 2001 | ||
From: Takashi Yano <[email protected]> | ||
Date: Fri, 2 Feb 2024 13:59:19 +0900 | ||
Subject: [PATCH 76/N] Cygwin: console: Fix exit code for non-cygwin process. | ||
|
||
If non-cygwin process is executed in console, the exit code is not | ||
set correctly. This is because the stub process for non-cygwin app | ||
crashes in fhandler_console::set_disable_master_thread() due to NULL | ||
pointer dereference. This bug was introduced by the commit: | ||
3721a756b0d8 ("Cygwin: console: Make the console accessible from | ||
other terminals."), that the pointer cons is accessed before fixing | ||
when it is NULL. This patch fixes the issue. | ||
|
||
Backported-from: aa73e11524 (Cygwin: console: Fix exit code for non-cygwin process., 2024-02-02) | ||
Fixes: 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals.") | ||
Reported-by: Johannes Schindelin <[email protected]> | ||
Signed-off-by: Takashi Yano <[email protected]> | ||
Signed-off-by: Johannes Schindelin <[email protected]> | ||
--- | ||
winsup/cygwin/fhandler/console.cc | 4 ++-- | ||
1 file changed, 2 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc | ||
index 1fe72fc..edcc484 100644 | ||
--- a/winsup/cygwin/fhandler/console.cc | ||
+++ b/winsup/cygwin/fhandler/console.cc | ||
@@ -4344,8 +4344,6 @@ fhandler_console::need_console_handler () | ||
void | ||
fhandler_console::set_disable_master_thread (bool x, fhandler_console *cons) | ||
{ | ||
- if (con.disable_master_thread == x) | ||
- return; | ||
if (cons == NULL) | ||
{ | ||
if (cygheap->ctty && cygheap->ctty->get_major () == DEV_CONS_MAJOR) | ||
@@ -4353,6 +4351,8 @@ fhandler_console::set_disable_master_thread (bool x, fhandler_console *cons) | ||
else | ||
return; | ||
} | ||
+ if (con.disable_master_thread == x) | ||
+ return; | ||
cons->acquire_input_mutex (mutex_timeout); | ||
con.disable_master_thread = x; | ||
cons->release_input_mutex (); |
32 changes: 32 additions & 0 deletions
32
msys2-runtime/0077-Cygwin-console-Avoid-slipping-past-disable_master_th.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
From d52d8f79398e5605f1224de14ea4bef0841a7f8e Mon Sep 17 00:00:00 2001 | ||
From: Takashi Yano <[email protected]> | ||
Date: Sat, 3 Feb 2024 00:54:23 +0900 | ||
Subject: [PATCH 77/N] Cygwin: console: Avoid slipping past | ||
disable_master_thread check. | ||
|
||
If disable_master_thread flag is set between the code checking that | ||
flag not be set and the code acquiring input_mutex, input record is | ||
processed once after setting disable_master_thread flag. This patch | ||
prevents that. | ||
|
||
Backported-from: 9bcfd06045 (Cygwin: console: Avoid slipping past disable_master_thread check., 2024-02-03) | ||
Fixes: d4aacd50e6cf ("Cygwin: console: Add missing input_mutex guard.") | ||
Signed-off-by: Takashi Yano <[email protected]> | ||
Signed-off-by: Johannes Schindelin <[email protected]> | ||
--- | ||
winsup/cygwin/fhandler/console.cc | 2 -- | ||
1 file changed, 2 deletions(-) | ||
|
||
diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc | ||
index edcc484..f9a6946 100644 | ||
--- a/winsup/cygwin/fhandler/console.cc | ||
+++ b/winsup/cygwin/fhandler/console.cc | ||
@@ -4351,8 +4351,6 @@ fhandler_console::set_disable_master_thread (bool x, fhandler_console *cons) | ||
else | ||
return; | ||
} | ||
- if (con.disable_master_thread == x) | ||
- return; | ||
cons->acquire_input_mutex (mutex_timeout); | ||
con.disable_master_thread = x; | ||
cons->release_input_mutex (); |
110 changes: 110 additions & 0 deletions
110
msys2-runtime/0078-Cygwin-pipe-Give-up-to-use-query_hdl-for-non-cygwin-.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
From a4bd6e9733cf85914843ad7ea7e9f54417dce9fb Mon Sep 17 00:00:00 2001 | ||
From: Takashi Yano <[email protected]> | ||
Date: Sun, 3 Mar 2024 13:44:17 +0900 | ||
Subject: [PATCH 78/N] Cygwin: pipe: Give up to use query_hdl for non-cygwin | ||
apps. | ||
|
||
Non-cygwin app may call ReadFile() for empty pipe, which makes | ||
NtQueryObject() for ObjectNameInformation block in fhandler_pipe:: | ||
get_query_hdl_per_process. Therefore, do not to try to get query_hdl | ||
for non-cygwin apps. | ||
|
||
Addresses: https://github.com/msys2/msys2-runtime/issues/202 | ||
|
||
Backported-from: f6be372ace (Cygwin: pipe: Give up to use query_hdl for non-cygwin apps., 2024-03-03) | ||
Fixes: b531d6b06eeb ("Cygwin: pipe: Introduce temporary query_hdl.") | ||
Reported-by: Alisa Sireneva, Johannes Schindelin <[email protected]> | ||
Reviewed-by: Corinna Vinschen <[email protected]> | ||
Signed-off-by: Takashi Yano <[email protected]> | ||
Signed-off-by: Johannes Schindelin <[email protected]> | ||
--- | ||
winsup/cygwin/fhandler/pipe.cc | 57 ++++++++-------------------------- | ||
1 file changed, 13 insertions(+), 44 deletions(-) | ||
|
||
diff --git a/winsup/cygwin/fhandler/pipe.cc b/winsup/cygwin/fhandler/pipe.cc | ||
index 283319c..05b1625 100644 | ||
--- a/winsup/cygwin/fhandler/pipe.cc | ||
+++ b/winsup/cygwin/fhandler/pipe.cc | ||
@@ -1207,53 +1207,24 @@ HANDLE | ||
fhandler_pipe::get_query_hdl_per_process (WCHAR *name, | ||
OBJECT_NAME_INFORMATION *ntfn) | ||
{ | ||
- NTSTATUS status; | ||
- ULONG len; | ||
- DWORD n_process = 256; | ||
- PSYSTEM_PROCESS_INFORMATION spi; | ||
- do | ||
- { /* Enumerate processes */ | ||
- DWORD nbytes = n_process * sizeof (SYSTEM_PROCESS_INFORMATION); | ||
- spi = (PSYSTEM_PROCESS_INFORMATION) HeapAlloc (GetProcessHeap (), | ||
- 0, nbytes); | ||
- if (!spi) | ||
- return NULL; | ||
- status = NtQuerySystemInformation (SystemProcessInformation, | ||
- spi, nbytes, &len); | ||
- if (NT_SUCCESS (status)) | ||
- break; | ||
- HeapFree (GetProcessHeap (), 0, spi); | ||
- n_process *= 2; | ||
- } | ||
- while (n_process < (1L<<20) && status == STATUS_INFO_LENGTH_MISMATCH); | ||
- if (!NT_SUCCESS (status)) | ||
- return NULL; | ||
+ winpids pids ((DWORD) 0); | ||
|
||
- /* In most cases, it is faster to check the processes in reverse order. | ||
- To do this, store PIDs into an array. */ | ||
- DWORD *proc_pids = (DWORD *) HeapAlloc (GetProcessHeap (), 0, | ||
- n_process * sizeof (DWORD)); | ||
- if (!proc_pids) | ||
+ /* In most cases, it is faster to check the processes in reverse order. */ | ||
+ for (LONG i = (LONG) pids.npids - 1; i >= 0; i--) | ||
{ | ||
- HeapFree (GetProcessHeap (), 0, spi); | ||
- return NULL; | ||
- } | ||
- PSYSTEM_PROCESS_INFORMATION p = spi; | ||
- n_process = 0; | ||
- while (true) | ||
- { | ||
- proc_pids[n_process++] = (DWORD)(intptr_t) p->UniqueProcessId; | ||
- if (!p->NextEntryOffset) | ||
- break; | ||
- p = (PSYSTEM_PROCESS_INFORMATION) ((char *) p + p->NextEntryOffset); | ||
- } | ||
- HeapFree (GetProcessHeap (), 0, spi); | ||
+ NTSTATUS status; | ||
+ ULONG len; | ||
+ | ||
+ /* Non-cygwin app may call ReadFile() for empty pipe, which makes | ||
+ NtQueryObject() for ObjectNameInformation block. Therefore, do | ||
+ not try to get query_hdl for non-cygwin apps. */ | ||
+ _pinfo *p = pids[i]; | ||
+ if (!p || ISSTATE (p, PID_NOTCYGWIN)) | ||
+ continue; | ||
|
||
- for (LONG i = (LONG) n_process - 1; i >= 0; i--) | ||
- { | ||
HANDLE proc = OpenProcess (PROCESS_DUP_HANDLE | ||
| PROCESS_QUERY_INFORMATION, | ||
- 0, proc_pids[i]); | ||
+ 0, p->dwProcessId); | ||
if (!proc) | ||
continue; | ||
|
||
@@ -1317,7 +1288,6 @@ fhandler_pipe::get_query_hdl_per_process (WCHAR *name, | ||
query_hdl_proc = proc; | ||
query_hdl_value = (HANDLE)(intptr_t) phi->Handles[j].HandleValue; | ||
HeapFree (GetProcessHeap (), 0, phi); | ||
- HeapFree (GetProcessHeap (), 0, proc_pids); | ||
return h; | ||
} | ||
close_handle: | ||
@@ -1327,7 +1297,6 @@ close_handle: | ||
close_proc: | ||
CloseHandle (proc); | ||
} | ||
- HeapFree (GetProcessHeap (), 0, proc_pids); | ||
return NULL; | ||
} | ||
|
176 changes: 176 additions & 0 deletions
176
msys2-runtime/0079-Cygwin-pipe-Make-sure-to-set-read-pipe-non-blocking-.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
From a4d92d60dc618a2c1207dab20dcd04b4fb7cb541 Mon Sep 17 00:00:00 2001 | ||
From: Takashi Yano <[email protected]> | ||
Date: Mon, 11 Mar 2024 22:08:00 +0900 | ||
Subject: [PATCH 79/N] Cygwin: pipe: Make sure to set read pipe non-blocking | ||
for cygwin apps. | ||
|
||
If pipe reader is a non-cygwin app first, and cygwin process reads | ||
the same pipe after that, the pipe has been set to bclocking mode | ||
for the cygwin app. However, the commit 9e4d308cd592 assumes the | ||
pipe for cygwin process always is non-blocking mode. With this patch, | ||
the pipe mode is reset to non-blocking when cygwin app is started. | ||
|
||
Backported-from: 55431b408e (Cygwin: pipe: Make sure to set read pipe non-blocking for cygwin apps., 2024-03-11) | ||
Addresses: https://cygwin.com/pipermail/cygwin/2024-March/255644.html | ||
Fixes: 9e4d308cd592 ("Cygwin: pipe: Adopt FILE_SYNCHRONOUS_IO_NONALERT flag for read pipe.") | ||
Reported-by: wh <[email protected]> | ||
Reviewed-by: Corinna Vinschen <[email protected]> | ||
Signed-off-by: Takashi Yano <[email protected]> | ||
Signed-off-by: Johannes Schindelin <[email protected]> | ||
--- | ||
winsup/cygwin/fhandler/pipe.cc | 63 +++++++++++++++++++++++++ | ||
winsup/cygwin/local_includes/fhandler.h | 3 ++ | ||
winsup/cygwin/spawn.cc | 34 +------------ | ||
3 files changed, 68 insertions(+), 32 deletions(-) | ||
|
||
diff --git a/winsup/cygwin/fhandler/pipe.cc b/winsup/cygwin/fhandler/pipe.cc | ||
index 05b1625..8daae8d 100644 | ||
--- a/winsup/cygwin/fhandler/pipe.cc | ||
+++ b/winsup/cygwin/fhandler/pipe.cc | ||
@@ -18,6 +18,7 @@ details. */ | ||
#include "pinfo.h" | ||
#include "shared_info.h" | ||
#include "tls_pbuf.h" | ||
+#include "sigproc.h" | ||
#include <assert.h> | ||
|
||
/* This is only to be used for writing. When reading, | ||
@@ -587,6 +588,17 @@ fhandler_pipe::fixup_after_fork (HANDLE parent) | ||
ReleaseMutex (hdl_cnt_mtx); | ||
} | ||
|
||
+void | ||
+fhandler_pipe::fixup_after_exec () | ||
+{ | ||
+ /* Set read pipe itself always non-blocking for cygwin process. | ||
+ Blocking/non-blocking is simulated in raw_read(). For write | ||
+ pipe, follow is_nonblocking(). */ | ||
+ bool mode = get_device () == FH_PIPEW ? is_nonblocking () : true; | ||
+ set_pipe_non_blocking (mode); | ||
+ fhandler_base::fixup_after_exec (); | ||
+} | ||
+ | ||
int | ||
fhandler_pipe::dup (fhandler_base *child, int flags) | ||
{ | ||
@@ -1370,3 +1382,54 @@ close_proc: | ||
HeapFree (GetProcessHeap (), 0, shi); | ||
return NULL; | ||
} | ||
+ | ||
+void | ||
+fhandler_pipe::spawn_worker (int fileno_stdin, int fileno_stdout, | ||
+ int fileno_stderr) | ||
+{ | ||
+ bool need_send_noncygchld_sig = false; | ||
+ | ||
+ /* spawn_worker() is called from spawn.cc only when non-cygwin app | ||
+ is started. Set pipe mode blocking for the non-cygwin process. */ | ||
+ int fd; | ||
+ cygheap_fdenum cfd (false); | ||
+ while ((fd = cfd.next ()) >= 0) | ||
+ if (cfd->get_dev () == FH_PIPEW | ||
+ && (fd == fileno_stdout || fd == fileno_stderr)) | ||
+ { | ||
+ fhandler_pipe *pipe = (fhandler_pipe *)(fhandler_base *) cfd; | ||
+ pipe->set_pipe_non_blocking (false); | ||
+ | ||
+ /* Setup for query_ndl stuff. Read the comment below. */ | ||
+ if (pipe->request_close_query_hdl ()) | ||
+ need_send_noncygchld_sig = true; | ||
+ } | ||
+ else if (cfd->get_dev () == FH_PIPER && fd == fileno_stdin) | ||
+ { | ||
+ fhandler_pipe *pipe = (fhandler_pipe *)(fhandler_base *) cfd; | ||
+ pipe->set_pipe_non_blocking (false); | ||
+ } | ||
+ | ||
+ /* If multiple writers including non-cygwin app exist, the non-cygwin | ||
+ app cannot detect pipe closure on the read side when the pipe is | ||
+ created by system account or the pipe creator is running as service. | ||
+ This is because query_hdl which is held in write side also is a read | ||
+ end of the pipe, so the pipe is still alive for the non-cygwin app | ||
+ even after the reader is closed. | ||
+ | ||
+ To avoid this problem, let all processes in the same process | ||
+ group close query_hdl using internal signal __SIGNONCYGCHLD when | ||
+ non-cygwin app is started. */ | ||
+ if (need_send_noncygchld_sig) | ||
+ { | ||
+ tty_min dummy_tty; | ||
+ dummy_tty.ntty = (fh_devices) myself->ctty; | ||
+ dummy_tty.pgid = myself->pgid; | ||
+ tty_min *t = cygwin_shared->tty.get_cttyp (); | ||
+ if (!t) /* If tty is not allocated, use dummy_tty instead. */ | ||
+ t = &dummy_tty; | ||
+ /* Emit __SIGNONCYGCHLD to let all processes in the | ||
+ process group close query_hdl. */ | ||
+ t->kill_pgrp (__SIGNONCYGCHLD); | ||
+ } | ||
+} | ||
diff --git a/winsup/cygwin/local_includes/fhandler.h b/winsup/cygwin/local_includes/fhandler.h | ||
index 649a431..15b19f7 100644 | ||
--- a/winsup/cygwin/local_includes/fhandler.h | ||
+++ b/winsup/cygwin/local_includes/fhandler.h | ||
@@ -1212,6 +1212,7 @@ public: | ||
int open (int flags, mode_t mode = 0); | ||
bool open_setup (int flags); | ||
void fixup_after_fork (HANDLE); | ||
+ void fixup_after_exec (); | ||
int dup (fhandler_base *child, int); | ||
void set_close_on_exec (bool val); | ||
int close (); | ||
@@ -1273,6 +1274,8 @@ public: | ||
} | ||
return false; | ||
} | ||
+ static void spawn_worker (int fileno_stdin, int fileno_stdout, | ||
+ int fileno_stderr); | ||
}; | ||
|
||
#define CYGWIN_FIFO_PIPE_NAME_LEN 47 | ||
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc | ||
index 383f5e5..acdef49 100644 | ||
--- a/winsup/cygwin/spawn.cc | ||
+++ b/winsup/cygwin/spawn.cc | ||
@@ -607,38 +607,8 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, | ||
int fileno_stderr = 2; | ||
|
||
if (!iscygwin ()) | ||
- { | ||
- bool need_send_sig = false; | ||
- int fd; | ||
- cygheap_fdenum cfd (false); | ||
- while ((fd = cfd.next ()) >= 0) | ||
- if (cfd->get_dev () == FH_PIPEW | ||
- && (fd == fileno_stdout || fd == fileno_stderr)) | ||
- { | ||
- fhandler_pipe *pipe = (fhandler_pipe *)(fhandler_base *) cfd; | ||
- pipe->set_pipe_non_blocking (false); | ||
- if (pipe->request_close_query_hdl ()) | ||
- need_send_sig = true; | ||
- } | ||
- else if (cfd->get_dev () == FH_PIPER && fd == fileno_stdin) | ||
- { | ||
- fhandler_pipe *pipe = (fhandler_pipe *)(fhandler_base *) cfd; | ||
- pipe->set_pipe_non_blocking (false); | ||
- } | ||
- | ||
- if (need_send_sig) | ||
- { | ||
- tty_min dummy_tty; | ||
- dummy_tty.ntty = (fh_devices) myself->ctty; | ||
- dummy_tty.pgid = myself->pgid; | ||
- tty_min *t = cygwin_shared->tty.get_cttyp (); | ||
- if (!t) /* If tty is not allocated, use dummy_tty instead. */ | ||
- t = &dummy_tty; | ||
- /* Emit __SIGNONCYGCHLD to let all processes in the | ||
- process group close query_hdl. */ | ||
- t->kill_pgrp (__SIGNONCYGCHLD); | ||
- } | ||
- } | ||
+ fhandler_pipe::spawn_worker (fileno_stdin, fileno_stdout, | ||
+ fileno_stderr); | ||
|
||
bool no_pcon = mode != _P_OVERLAY && mode != _P_WAIT; | ||
term_spawn_worker.setup (iscygwin (), handle (fileno_stdin, false), |
Oops, something went wrong.