https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a4584410fc24486eae272c6e6a582eb27757314c

commit a4584410fc24486eae272c6e6a582eb27757314c
Author:     Corinna Vinschen <[email protected]>
AuthorDate: Tue Jan 10 11:45:28 2023 +0100
Commit:     Corinna Vinschen <[email protected]>
CommitDate: Tue Jan 10 11:49:08 2023 +0100

    Cygwin: /proc/<PID>/status: avoid crash computing signal info
    
    The code computing the mask of pending signals used the per-queued
    signal TLS pointer without checking it for NULL.  Fix this by using
    the process-wide signal mask in that case.
    
    Fixes: 195169186bfd5 ("Cygwin: wait_sig: allow to compute process-wide mask 
of pending signals")
    Signed-off-by: Corinna Vinschen <[email protected]>

Diff:
---
 winsup/cygwin/release/3.4.4 | 3 +++
 winsup/cygwin/sigproc.cc    | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/release/3.4.4 b/winsup/cygwin/release/3.4.4
index a653b08a1a40..35d746ba08fd 100644
--- a/winsup/cygwin/release/3.4.4
+++ b/winsup/cygwin/release/3.4.4
@@ -10,3 +10,6 @@ Bug Fixes
 
 - Reinstantiate exporting _alloca.
   Addresses: https://cygwin.com/pipermail/cygwin/2023-January/252797.html
+
+- Avoid hangs when reading /proc/<PID>/status.
+  Addresses: https://cygwin.com/pipermail/cygwin/2022-December/252756.html
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index a99876dc9fb9..fd3291c1bcfe 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -1382,7 +1382,8 @@ wait_sig (VOID *)
            *pack.mask = 0;
            while ((q = q->next))
              {
-               if (q->sigtls->sigmask & (bit = SIGTOMASK (q->si.si_signo)))
+               _cygtls *sigtls = q->sigtls ?: _main_tls;
+               if (sigtls->sigmask & (bit = SIGTOMASK (q->si.si_signo)))
                  {
                    tl_entry = cygheap->find_tls (q->si.si_signo, issig_wait);
                    if (tl_entry)

Reply via email to