diff options
author | Takashi Yano <takashi.yano@nifty.ne.jp> | 2022-01-13 18:16:31 +0900 |
---|---|---|
committer | Takashi Yano <takashi.yano@nifty.ne.jp> | 2022-01-14 23:10:47 +0900 |
commit | aa49985245e4e5b278778b0a47f6ce83cceb4ad4 (patch) | |
tree | 806f3df1039ebcd9baf0ded22eaa122e3b97642d /winsup/cygwin/spawn.cc | |
parent | 7e8031a5fd356f205e08a3297d8da83f42e6b8ae (diff) | |
download | newlib-aa49985245e4e5b278778b0a47f6ce83cceb4ad4.zip newlib-aa49985245e4e5b278778b0a47f6ce83cceb4ad4.tar.gz newlib-aa49985245e4e5b278778b0a47f6ce83cceb4ad4.tar.bz2 |
Cygwin: pty, console: Fix deadlock in GDB regarding mutex.
- GDB inferior may be suspended while the inferior grabs mutex.
This causes deadlock in terminal I/O. With this patch, timeout
for waiting mutex is set to 0 for the debugger process when the
process calls CreateProcess() with DEBUG_PROCESS flag to avoid
deadlock. This may cause the race issue in GDB, however, there
is no other way than that.
Addresses:
https://cygwin.com/pipermail/cygwin-developers/2021-December/012542.html
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r-- | winsup/cygwin/spawn.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index b93063d..81dba5a 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -272,6 +272,8 @@ child_info_spawn NO_COPY ch_spawn; extern "C" void __posix_spawn_sem_release (void *sem, int error); +extern DWORD mutex_timeout; /* defined in fhandler_termios.cc */ + int child_info_spawn::worker (const char *prog_arg, const char *const *argv, const char *const envp[], int mode, @@ -718,7 +720,7 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, && stdin_is_ptys && ptys_ttyp->pcon_input_state_eq (tty::to_cyg)) { - WaitForSingleObject (ptys_input_mutex, INFINITE); + WaitForSingleObject (ptys_input_mutex, mutex_timeout); fhandler_pty_slave::transfer_input (tty::to_nat, ptys_primary->get_handle (), ptys_ttyp, ptys_input_available_event); @@ -1011,7 +1013,7 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, if (ptys_ttyp->getpgid () == myself->pgid && stdin_is_ptys && ptys_ttyp->pcon_input_state_eq (tty::to_nat)) { - WaitForSingleObject (ptys_input_mutex, INFINITE); + WaitForSingleObject (ptys_input_mutex, mutex_timeout); fhandler_pty_slave::transfer_input (tty::to_cyg, ptys_from_master_nat, ptys_ttyp, ptys_input_available_event); @@ -1048,7 +1050,7 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, if (ptys_ttyp->getpgid () == myself->pgid && stdin_is_ptys && ptys_ttyp->pcon_input_state_eq (tty::to_nat)) { - WaitForSingleObject (ptys_input_mutex, INFINITE); + WaitForSingleObject (ptys_input_mutex, mutex_timeout); fhandler_pty_slave::transfer_input (tty::to_cyg, ptys_from_master_nat, ptys_ttyp, ptys_input_available_event); |