-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cygwin: signal: Do not handle signal when __SIGFLUSHFAST is sent #251
Cygwin: signal: Do not handle signal when __SIGFLUSHFAST is sent #251
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This member was renamed on master but not in 3.5 branch
After the commit d243e51, zsh sometimes hangs at startup. This occurs because SIGCHLD, which should trigger sigsuspend(), is handled in cygwait() that is used to wait for a wakeup event in sig_send(), even when __SIGFLUSHFAST is sent. Despite __SIGFLUSHFAST being required to return before handling the signal, this does not happen. With this patch, if the signal currently being sent is __SIGFLUSHFAST, do not handle the received signal and keep it asserted after the cygwait() for the wakeup event. Apply the same logic to the cygwait() in the retrying loop for WriteFile() as well. Applied-from: https://inbox.sourceware.org/cygwin-patches/20241223013332.1269-1-takashi.yano@nifty.ne.jp Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256954.html Fixes: d243e51 ("Cygwin: signal: Fix deadlock between main thread and sig thread") Reported-by: Daisuke Fujimura <booleanlabel@gmail.com> Reviewed-by: Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
6326293
to
f1affcc
Compare
Thanks @jeremyd2019! The build is now successful. |
I tested the msys-2.0.dll from the CI artifact on the arm64 autobuild, rebuilding imagemagick which hung 3 times in a row with 3.5.5-1, and it succeeded. |
Hrm. This is apparently still not good enough. I noticed that Git's test suite would time out after 6h with MSYS2 runtime v3.5.5, opened git-for-windows/msys2-runtime#80 to apply this here fix, and then triggered another Git test suite run. It looks like it is hanging again (albeit in less matrix jobs, which is good). |
Have you reported this to upstream Cygwin/Takashi? |
@jeremyd2019 No, I didn't have time to investigate yet... so I do not even have a reproducer. |
I spent quite a while on trying to reproduce, and unsurprisingly it is hard. It is almost certainly a race condition, indicating that some sort of locking is needed and just isn't there. I'll just jot down some notes to be able to jog my memory later: The test script in Git's test suite that I zoomed in on is I actually ran Apparently this was "lucky" because re-running that test script individually did not cause a hang. Then, I ran Now, this is where it gets interesting: both of those jobs got stuck in the first "test case" (Git's test suite uses a home-grown test framework that lacks modern test frameworks' features like "setup" and "teardown" functions, therefore the first test case frequently serves as a common "setup" step and it is quite normal, unfortunately so, for the test cases to depend on side effects of previous test cases; As you can tell, I am absolutely not a fan of the way Git's test suite is architected), when running The When I had Ctrl+C'ed the hung test script and there were still a couple of left-over processes blocking the working directory of that test from being deleted, I had actually tried to make some sense of the process topology when that
I had to stop, manually (via This is an unsatisfying place to take a break from my investigation, but it'll have to do for now. Potential next steps:
|
This is odd, so far the issues that this patch helped could be killed with SIGTERM within Cygwin. |
There were two stuck jobs here right now: /~https://github.com/msys2/msys2-autobuild/actions/runs/12514784401/job/34911395541 |
To be honest, I did not even try the |
I tried to figure out what command it would be stuck in, but failed (I saw that |
I had a hang locally right now building gimp2. pstree shows this:
stack traces of sed and grep: sh (parent of grep and sed1)Thread 5 (Thread 17492.0x1438 "waitproc"):
#0 0x00007fffbb87f7e4 in ntdll!ZwReadFile () from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x00007fffb8ded16d in ReadFile () from /c/WINDOWS/System32/KERNELBASE.dll
#2 0x00000001800a1c14 in proc_waiter (arg=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/pinfo.cc:1268
#3 0x0000000180044e20 in cygthread::callfunc (this=this@entry=0x1802465e8 <threads+264>, issimplestub=issimplestub@entry=false) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:48
#4 0x00000001800453b9 in cygthread::stub (arg=arg@entry=0x1802465e8 <threads+264>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:91
#5 0x0000000180045fc3 in _cygtls::call2 (this=0x3a4ce00, func=0x180045350 <cygthread::stub(void*)>, arg=0x1802465e8 <threads+264>, buf=buf@entry=0x3a4cd50) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:41
#6 0x0000000180046074 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:28
#7 0x00007fffba9fe8d7 in KERNEL32!BaseThreadInitThunk () from /c/WINDOWS/System32/KERNEL32.DLL
#8 0x00007fffbb7ffbcc in ntdll!RtlUserThreadStart () from /c/WINDOWS/SYSTEM32/ntdll.dll
#9 0x0000000000000000 in ?? ()
Thread 4 (Thread 17492.0x2fb8 "waitproc"):
#0 0x00007fffbb87f7e4 in ntdll!ZwReadFile () from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x00007fffb8ded16d in ReadFile () from /c/WINDOWS/System32/KERNELBASE.dll
#2 0x00000001800a1c14 in proc_waiter (arg=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/pinfo.cc:1268
#3 0x0000000180044e20 in cygthread::callfunc (this=this@entry=0x180246590 <threads+176>, issimplestub=issimplestub@entry=false) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:48
#4 0x00000001800453b9 in cygthread::stub (arg=arg@entry=0x180246590 <threads+176>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:91
#5 0x0000000180045fc3 in _cygtls::call2 (this=0x384ce00, func=0x180045350 <cygthread::stub(void*)>, arg=0x180246590 <threads+176>, buf=buf@entry=0x384cd50) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:41
#6 0x0000000180046074 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:28
#7 0x00007fffba9fe8d7 in KERNEL32!BaseThreadInitThunk () from /c/WINDOWS/System32/KERNEL32.DLL
#8 0x00007fffbb7ffbcc in ntdll!RtlUserThreadStart () from /c/WINDOWS/SYSTEM32/ntdll.dll
#9 0x0000000000000000 in ?? ()
Thread 3 (Thread 17492.0x4474 "waitproc"):
#0 0x00007fffbb87f7e4 in ntdll!ZwReadFile () from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x00007fffb8ded16d in ReadFile () from /c/WINDOWS/System32/KERNELBASE.dll
#2 0x00000001800a1c14 in proc_waiter (arg=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/pinfo.cc:1268
#3 0x0000000180044e20 in cygthread::callfunc (this=this@entry=0x180246538 <threads+88>, issimplestub=issimplestub@entry=false) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:48
#4 0x00000001800453b9 in cygthread::stub (arg=arg@entry=0x180246538 <threads+88>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:91
#5 0x0000000180045fc3 in _cygtls::call2 (this=0x364ce00, func=0x180045350 <cygthread::stub(void*)>, arg=0x180246538 <threads+88>, buf=buf@entry=0x364cd50) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:41
#6 0x0000000180046074 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:28
--Type <RET> for more, q to quit, c to continue without paging--
#7 0x00007fffba9fe8d7 in KERNEL32!BaseThreadInitThunk () from /c/WINDOWS/System32/KERNEL32.DLL
#8 0x00007fffbb7ffbcc in ntdll!RtlUserThreadStart () from /c/WINDOWS/SYSTEM32/ntdll.dll
#9 0x0000000000000000 in ?? ()
Thread 2 (Thread 17492.0x274c "sig"):
#0 0x00007fffbb87f7e4 in ntdll!ZwReadFile () from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x00007fffb8ded16d in ReadFile () from /c/WINDOWS/System32/KERNELBASE.dll
#2 0x00000001800c51f7 in wait_sig () at /c/S/B/src/msys2-runtime/winsup/cygwin/sigproc.cc:1378
#3 0x0000000180044e20 in cygthread::callfunc (this=this@entry=0x1802464e0 <threads>, issimplestub=issimplestub@entry=false) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:48
#4 0x00000001800453b9 in cygthread::stub (arg=arg@entry=0x1802464e0 <threads>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:91
#5 0x0000000180045fc3 in _cygtls::call2 (this=0x291ce00, func=0x180045350 <cygthread::stub(void*)>, arg=0x1802464e0 <threads>, buf=buf@entry=0x291cd50) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:41
#6 0x0000000180046074 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:28
#7 0x00007fffba9fe8d7 in KERNEL32!BaseThreadInitThunk () from /c/WINDOWS/System32/KERNEL32.DLL
#8 0x00007fffbb7ffbcc in ntdll!RtlUserThreadStart () from /c/WINDOWS/SYSTEM32/ntdll.dll
#9 0x0000000000000000 in ?? ()
Thread 1 (Thread 17492.0x1508 "sh"):
#0 0x00007fffbb880274 in ntdll!ZwWaitForMultipleObjects () from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x00007fffb8dedc23 in WaitForMultipleObjectsEx () from /c/WINDOWS/System32/KERNELBASE.dll
#2 0x00007fffb8dedaf1 in WaitForMultipleObjects () from /c/WINDOWS/System32/KERNELBASE.dll
#3 0x00000001800461de in cygwait (object=<optimized out>, timeout=timeout@entry=0x0, mask=mask@entry=3) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygwait.cc:75
#4 0x00000001800f0cb7 in wait4 (intpid=-1, status=<optimized out>, options=0, r=0x0) at /c/S/B/src/msys2-runtime/winsup/cygwin/wait.cc:80
#5 0x000000018019a33b in _sigfe () at sigfe.s:36 sed 1Thread 2 (Thread 18032.0x41e0 "sig"):
#0 0x00007fffbb87f7e4 in ntdll!ZwReadFile () from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x00007fffb8ded16d in ReadFile () from /c/WINDOWS/System32/KERNELBASE.dll
#2 0x00000001800c51f7 in wait_sig () at /c/S/B/src/msys2-runtime/winsup/cygwin/sigproc.cc:1378
#3 0x0000000180044e20 in cygthread::callfunc (this=this@entry=0x1802464e0 <threads>, issimplestub=issimplestub@entry=false) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:48
#4 0x00000001800453b9 in cygthread::stub (arg=arg@entry=0x1802464e0 <threads>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:91
#5 0x0000000180045fc3 in _cygtls::call2 (this=0x115ce00, func=0x180045350 <cygthread::stub(void*)>, arg=0x1802464e0 <threads>, buf=buf@entry=0x115cd50) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:41
#6 0x0000000180046074 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:28
#7 0x00007fffba9fe8d7 in KERNEL32!BaseThreadInitThunk () from /c/WINDOWS/System32/KERNEL32.DLL
#8 0x00007fffbb7ffbcc in ntdll!RtlUserThreadStart () from /c/WINDOWS/SYSTEM32/ntdll.dll
#9 0x0000000000000000 in ?? ()
Thread 1 (Thread 18032.0x1d7c "sed"):
--Type <RET> for more, q to quit, c to continue without paging--
#0 0x00007fffbb87f944 in ntdll!ZwQueryInformationFile () from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x000000018012bac4 in fhandler_pipe::raw_read (this=0x800021240, ptr=0xa000023a0, len=@0x7ffffc800: 65536) at /c/S/B/src/msys2-runtime/winsup/cygwin/fhandler/pipe.cc:342
#2 0x00000001800ff173 in fhandler_base::read (this=0x800021240, in_ptr=0xa000023a0, len=@0x7ffffc800: 65536) at /c/S/B/src/msys2-runtime/winsup/cygwin/fhandler/base.cc:839
#3 0x00000001800d4614 in read (fd=0, ptr=ptr@entry=0xa000023a0, len=<optimized out>, len@entry=65536) at /c/S/B/src/msys2-runtime/winsup/cygwin/local_includes/dtable.h:64
#4 0x00000001801f59e3 in _read_r (ptr=ptr@entry=0x7ffffce00, fd=<optimized out>, buf=buf@entry=0xa000023a0, cnt=cnt@entry=65536) at /c/S/B/src/msys2-runtime/newlib/libc/reent/readr.c:49
#5 0x00000001801e1a44 in __sread (ptr=0x7ffffce00, cookie=0xa00001f98, buf=0xa000023a0 "", n=65536) at /c/S/B/src/msys2-runtime/newlib/libc/stdio/stdio.c:47
#6 0x00000001801e0e45 in __srefill_r (ptr=0x7ffffce00, fp=fp@entry=0xa00001f98) at /c/S/B/src/msys2-runtime/newlib/libc/stdio/refill.c:113
#7 0x00000001801e1010 in __srget_r (ptr=<optimized out>, ptr@entry=0x7ffffce00, fp=fp@entry=0xa00001f98) at /c/S/B/src/msys2-runtime/newlib/libc/stdio/rget.c:47
#8 0x00000001801e015b in __sgetc_r (__p=0xa00001f98, __ptr=0x7ffffce00) at /c/S/B/src/msys2-runtime/newlib/libc/include/stdio.h:675
#9 getc_unlocked (fp=fp@entry=0xa00001f98) at /c/S/B/src/msys2-runtime/newlib/libc/stdio/getc_u.c:85
#10 0x00000001801e02a0 in __getdelim (bufptr=0x10042d140, n=0x10042d138, delim=10, fp=0xa00001f98) at /c/S/B/src/msys2-runtime/newlib/libc/stdio/getdelim.c:87
#11 0x000000018019a33b in _sigfe () at sigfe.s:36 sed 2Thread 2 (Thread 16220.0x32fc "sig"):
#0 0x00007fffbb87f7e4 in ntdll!ZwReadFile () from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x00007fffb8ded16d in ReadFile () from /c/WINDOWS/System32/KERNELBASE.dll
#2 0x00000001800c51f7 in wait_sig () at /c/S/B/src/msys2-runtime/winsup/cygwin/sigproc.cc:1378
#3 0x0000000180044e20 in cygthread::callfunc (this=this@entry=0x1802464e0 <threads>, issimplestub=issimplestub@entry=false) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:48
#4 0x00000001800453b9 in cygthread::stub (arg=arg@entry=0x1802464e0 <threads>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:91
#5 0x0000000180045fc3 in _cygtls::call2 (this=0x10cce00, func=0x180045350 <cygthread::stub(void*)>, arg=0x1802464e0 <threads>, buf=buf@entry=0x10ccd50) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:41
#6 0x0000000180046074 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:28
#7 0x00007fffba9fe8d7 in KERNEL32!BaseThreadInitThunk () from /c/WINDOWS/System32/KERNEL32.DLL
#8 0x00007fffbb7ffbcc in ntdll!RtlUserThreadStart () from /c/WINDOWS/SYSTEM32/ntdll.dll
#9 0x0000000000000000 in ?? ()
Thread 1 (Thread 16220.0x4a04 "sed"):
#0 0x00007fffbb880274 in ntdll!ZwWaitForMultipleObjects () from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x00007fffb8dedc23 in WaitForMultipleObjectsEx () from /c/WINDOWS/System32/KERNELBASE.dll
#2 0x00007fffb8dedaf1 in WaitForMultipleObjects () from /c/WINDOWS/System32/KERNELBASE.dll
#3 0x00000001800461de in cygwait (object=<optimized out>, timeout=timeout@entry=0x7ffffc648, mask=mask@entry=5) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygwait.cc:75
#4 0x000000018012bd2a in cygwait (mask=5, howlong=<optimized out>, h=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/local_includes/cygwait.h:45
#5 cygwait (howlong=<optimized out>, h=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/local_includes/cygwait.h:51
#6 fhandler_pipe::raw_read (this=0x800021920, ptr=0xa000049f0, len=@0x7ffffc800: 65536) at /c/S/B/src/msys2-runtime/winsup/cygwin/fhandler/pipe.cc:397
#7 0x00000001800ff173 in fhandler_base::read (this=0x800021920, in_ptr=0xa000049f0, len=@0x7ffffc800: 65536) at /c/S/B/src/msys2-runtime/winsup/cygwin/fhandler/base.cc:839
#8 0x00000001800d4614 in read (fd=0, ptr=ptr@entry=0xa000049f0, len=<optimized out>, len@entry=65536) at /c/S/B/src/msys2-runtime/winsup/cygwin/local_includes/dtable.h:64
#9 0x00000001801f59e3 in _read_r (ptr=ptr@entry=0x7ffffce00, fd=<optimized out>, buf=buf@entry=0xa000049f0, cnt=cnt@entry=65536) at /c/S/B/src/msys2-runtime/newlib/libc/reent/readr.c:49
#10 0x00000001801e1a44 in __sread (ptr=0x7ffffce00, cookie=0xa00004678, buf=0xa000049f0 '\001' <repeats 200 times>..., n=65536) at /c/S/B/src/msys2-runtime/newlib/libc/stdio/stdio.c:47
#11 0x00000001801e0e45 in __srefill_r (ptr=0x7ffffce00, fp=fp@entry=0xa00004678) at /c/S/B/src/msys2-runtime/newlib/libc/stdio/refill.c:113
#12 0x00000001801e1010 in __srget_r (ptr=<optimized out>, ptr@entry=0x7ffffce00, fp=fp@entry=0xa00004678) at /c/S/B/src/msys2-runtime/newlib/libc/stdio/rget.c:47
#13 0x00000001801e015b in __sgetc_r (__p=0xa00004678, __ptr=0x7ffffce00) at /c/S/B/src/msys2-runtime/newlib/libc/include/stdio.h:675
#14 getc_unlocked (fp=fp@entry=0xa00004678) at /c/S/B/src/msys2-runtime/newlib/libc/stdio/getc_u.c:85
#15 0x00000001801e02a0 in __getdelim (bufptr=0x10042d140, n=0x10042d138, delim=10, fp=0xa00004678) at /c/S/B/src/msys2-runtime/newlib/libc/stdio/getdelim.c:87
#16 0x000000018019a33b in _sigfe () at sigfe.s:36 grepThread 3 (Thread 11964.0x441c):
#0 0x00007fffbb8833d4 in ntdll!ZwWaitForWorkViaWorkerFactory () from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x00007fffbb771d7e in ntdll!TpCallbackMayRunLong () from /c/WINDOWS/SYSTEM32/ntdll.dll
#2 0x0000000180045fc3 in _cygtls::call2 (this=0x5fce00, func=0x7fffbb771a00 <ntdll!TpCallbackMayRunLong+5440>, arg=0x7d1a80, buf=buf@entry=0x5fcd50) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:41
#3 0x0000000180046074 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:28
#4 0x00007fffba9fe8d7 in KERNEL32!BaseThreadInitThunk () from /c/WINDOWS/System32/KERNEL32.DLL
#5 0x00007fffbb7ffbcc in ntdll!RtlUserThreadStart () from /c/WINDOWS/SYSTEM32/ntdll.dll
#6 0x0000000000000000 in ?? ()
Thread 2 (Thread 11964.0x4460 "sig"):
#0 0x00007fffbb87f7e4 in ntdll!ZwReadFile () from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x00007fffb8ded16d in ReadFile () from /c/WINDOWS/System32/KERNELBASE.dll
#2 0x00000001800c51f7 in wait_sig () at /c/S/B/src/msys2-runtime/winsup/cygwin/sigproc.cc:1378
#3 0x0000000180044e20 in cygthread::callfunc (this=this@entry=0x1802464e0 <threads>, issimplestub=issimplestub@entry=false) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:48
#4 0x00000001800453b9 in cygthread::stub (arg=arg@entry=0x1802464e0 <threads>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygthread.cc:91
#5 0x0000000180045fc3 in _cygtls::call2 (this=0x10cce00, func=0x180045350 <cygthread::stub(void*)>, arg=0x1802464e0 <threads>, buf=buf@entry=0x10ccd50) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:41
#6 0x0000000180046074 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygtls.cc:28
#7 0x00007fffba9fe8d7 in KERNEL32!BaseThreadInitThunk () from /c/WINDOWS/System32/KERNEL32.DLL
#8 0x00007fffbb7ffbcc in ntdll!RtlUserThreadStart () from /c/WINDOWS/SYSTEM32/ntdll.dll
#9 0x0000000000000000 in ?? ()
Thread 1 (Thread 11964.0x1be0 "grep"):
#0 0x00007fffbb880274 in ntdll!ZwWaitForMultipleObjects () from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x00007fffb8dedc23 in WaitForMultipleObjectsEx () from /c/WINDOWS/System32/KERNELBASE.dll
#2 0x00007fffb8dedaf1 in WaitForMultipleObjects () from /c/WINDOWS/System32/KERNELBASE.dll
#3 0x00000001800461de in cygwait (object=<optimized out>, timeout=timeout@entry=0x7ffffc648, mask=mask@entry=5) at /c/S/B/src/msys2-runtime/winsup/cygwin/cygwait.cc:75
#4 0x000000018012bd2a in cygwait (mask=5, howlong=<optimized out>, h=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/local_includes/cygwait.h:45
#5 cygwait (howlong=<optimized out>, h=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/local_includes/cygwait.h:51
#6 fhandler_pipe::raw_read (this=0x800038c40, ptr=0xa00010000, len=@0x7ffffc800: 65536) at /c/S/B/src/msys2-runtime/winsup/cygwin/fhandler/pipe.cc:397
#7 0x00000001800ff173 in fhandler_base::read (this=0x800038c40, in_ptr=0xa00010000, len=@0x7ffffc800: 65536) at /c/S/B/src/msys2-runtime/winsup/cygwin/fhandler/base.cc:839
#8 0x00000001800d4614 in read (fd=0, ptr=0xa00010000, len=<optimized out>) at /c/S/B/src/msys2-runtime/winsup/cygwin/local_includes/dtable.h:64
--Type <RET> for more, q to quit, c to continue without paging--
#9 0x000000018019a33b in _sigfe () at sigfe.s:36 |
I have a suspicion that it could be cygwin/cygwin@9c34e02, but I still have no reliable fast reproducer. |
@lazka, thanks for the stack trace. sh: sed1: sed2: grep: As for thread 2, each process has a thread that waits for the signal. So, it is normal thing that this thread is stopping on ReadFile(). Or is there non-msys2 process that writes to the pipe? |
That's almost certainly the case in Git for Windows' hangs. This used to be a well-supported scenario, could we please keep it that way? |
After the commit d243e51, zsh sometimes hangs at startup. This occurs because SIGCHLD, which should trigger sigsuspend(), is handled in cygwait() that is used to wait for a wakeup event in sig_send(), even when __SIGFLUSHFAST is sent. Despite __SIGFLUSHFAST being required to return before handling the signal, this does not happen. With this patch, if the signal currently being sent is __SIGFLUSHFAST, do not handle the received signal and keep it asserted after the cygwait() for the wakeup event. Apply the same logic to the cygwait() in the retrying loop for WriteFile() as well.
Applied-from: https://inbox.sourceware.org/cygwin-patches/20241223013332.1269-1-takashi.yano@nifty.ne.jp Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256954.html Fixes: d243e51 ("Cygwin: signal: Fix deadlock between main thread and sig thread")
Reported-by: Daisuke Fujimura booleanlabel@gmail.com
Reviewed-by: