Skip to content

Commit 62f6088

Browse files
jeremyd2019dscho
authored andcommitted
Cygwin: revert use of CancelSyncronousIo on wait_thread.
It appears this is causing hangs on native x86_64 in similar scenarios as the hangs on ARM64, because `CancelSynchronousIo` is returning `TRUE` but not canceling the `ReadFile` call as expected. Addresses: msys2/MSYS2-packages#4340 (comment) Fixes: b091b47 ("cygthread: suspend thread before terminating.") Signed-off-by: Jeremy Drake <[email protected]>
1 parent c94b46b commit 62f6088

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

winsup/cygwin/pinfo.cc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,17 +1262,13 @@ proc_waiter (void *arg)
12621262

12631263
for (;;)
12641264
{
1265-
DWORD nb, err;
1265+
DWORD nb;
12661266
char buf = '\0';
12671267

12681268
if (!ReadFile (vchild.rd_proc_pipe, &buf, 1, &nb, NULL)
1269-
&& (err = GetLastError ()) != ERROR_BROKEN_PIPE)
1269+
&& GetLastError () != ERROR_BROKEN_PIPE)
12701270
{
1271-
/* ERROR_OPERATION_ABORTED is expected due to the possibility that
1272-
CancelSynchronousIo interruped the ReadFile call, so don't output
1273-
that error */
1274-
if (err != ERROR_OPERATION_ABORTED)
1275-
system_printf ("error on read of child wait pipe %p, %E", vchild.rd_proc_pipe);
1271+
system_printf ("error on read of child wait pipe %p, %E", vchild.rd_proc_pipe);
12761272
break;
12771273
}
12781274

winsup/cygwin/sigproc.cc

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,7 @@ proc_terminate ()
413413
to 1 iff it is a Cygwin process. */
414414
if (!have_execed || !have_execed_cygwin)
415415
chld_procs[i]->ppid = 1;
416-
/* Attempt to exit the wait_thread cleanly via CancelSynchronousIo
417-
before falling back to the (explicitly dangerous) cross-thread
418-
termination */
419-
if (chld_procs[i].wait_thread
420-
&& !CancelSynchronousIo (chld_procs[i].wait_thread->thread_handle ()))
416+
if (chld_procs[i].wait_thread)
421417
chld_procs[i].wait_thread->terminate_thread ();
422418
/* Release memory associated with this process unless it is 'myself'.
423419
'myself' is only in the chld_procs table when we've execed. We
@@ -1202,11 +1198,7 @@ remove_proc (int ci)
12021198
{
12031199
if (have_execed)
12041200
{
1205-
/* Attempt to exit the wait_thread cleanly via CancelSynchronousIo
1206-
before falling back to the (explicitly dangerous) cross-thread
1207-
termination */
1208-
if (_my_tls._ctinfo != chld_procs[ci].wait_thread
1209-
&& !CancelSynchronousIo (chld_procs[ci].wait_thread->thread_handle ()))
1201+
if (_my_tls._ctinfo != chld_procs[ci].wait_thread)
12101202
chld_procs[ci].wait_thread->terminate_thread ();
12111203
}
12121204
else if (chld_procs[ci] && chld_procs[ci]->exists ())

0 commit comments

Comments
 (0)