public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/28607] New: Handles the masked signal when the thread exits
@ 2021-11-18 19:26 gb.gwon at stackframe dot dev
  2021-11-18 19:31 ` [Bug nptl/28607] Masked signals are delivered on thread exit fweimer at redhat dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gb.gwon at stackframe dot dev @ 2021-11-18 19:26 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28607

            Bug ID: 28607
           Summary: Handles the masked signal when the thread exits
           Product: glibc
           Version: 2.33
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: nptl
          Assignee: unassigned at sourceware dot org
          Reporter: gb.gwon at stackframe dot dev
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

Created attachment 13797
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13797&action=edit
signal.c

I am experiencing strange behavior when using pthread with signals.
If I set the signal mask with pthread_sigmask() in the thread function and the
process has pending signal when thread is exiting, signal handler executed in
thread.

sleep.c
-------
#include <unistd.h>

int main() {
        sleep(50);
        return 0;
}

Compile sleep.c and signal.c. Run `signal` and hit Ctrl + C in the middle of
running.

Result is like this.

$ ./signal
main thread: 139882152073024
child thread: 139882152068672
worker...
worker...
worker...
^Csigint: 139882152073024
worker...
worker...
worker...
worker...
worker...
worker...
worker...
thread close
sigchld: 139882152068672

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug nptl/28607] Masked signals are delivered on thread exit
  2021-11-18 19:26 [Bug nptl/28607] New: Handles the masked signal when the thread exits gb.gwon at stackframe dot dev
@ 2021-11-18 19:31 ` fweimer at redhat dot com
  2021-11-18 20:04 ` fweimer at redhat dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: fweimer at redhat dot com @ 2021-11-18 19:31 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28607

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-11-18
     Ever confirmed|0                           |1
              Flags|                            |security-
           Assignee|unassigned at sourceware dot org   |fweimer at redhat dot com
            Summary|Handles the masked signal   |Masked signals are
                   |when the thread exits       |delivered on thread exit

--- Comment #1 from Florian Weimer <fweimer at redhat dot com> ---
The signal mask initialization in start_thread happens in the wrong place.  I
have a fix.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug nptl/28607] Masked signals are delivered on thread exit
  2021-11-18 19:26 [Bug nptl/28607] New: Handles the masked signal when the thread exits gb.gwon at stackframe dot dev
  2021-11-18 19:31 ` [Bug nptl/28607] Masked signals are delivered on thread exit fweimer at redhat dot com
@ 2021-11-18 20:04 ` fweimer at redhat dot com
  2021-11-22  8:48 ` schwab@linux-m68k.org
  2021-11-24  8:21 ` fweimer at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: fweimer at redhat dot com @ 2021-11-18 20:04 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28607

--- Comment #2 from Florian Weimer <fweimer at redhat dot com> ---
Patch posted:
https://sourceware.org/pipermail/libc-alpha/2021-November/133272.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug nptl/28607] Masked signals are delivered on thread exit
  2021-11-18 19:26 [Bug nptl/28607] New: Handles the masked signal when the thread exits gb.gwon at stackframe dot dev
  2021-11-18 19:31 ` [Bug nptl/28607] Masked signals are delivered on thread exit fweimer at redhat dot com
  2021-11-18 20:04 ` fweimer at redhat dot com
@ 2021-11-22  8:48 ` schwab@linux-m68k.org
  2021-11-24  8:21 ` fweimer at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: schwab@linux-m68k.org @ 2021-11-22  8:48 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28607

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fryasu at yahoo dot co.jp

--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> ---
*** Bug 28612 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug nptl/28607] Masked signals are delivered on thread exit
  2021-11-18 19:26 [Bug nptl/28607] New: Handles the masked signal when the thread exits gb.gwon at stackframe dot dev
                   ` (2 preceding siblings ...)
  2021-11-22  8:48 ` schwab@linux-m68k.org
@ 2021-11-24  8:21 ` fweimer at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: fweimer at redhat dot com @ 2021-11-24  8:21 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28607

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |2.35
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Florian Weimer <fweimer at redhat dot com> ---
Fixed for glibc 2.35 via:

commit e186fc5a31e46f2cbf5ea1a75223b4412907f3d8
Author: Florian Weimer <fweimer@redhat.com>
Date:   Wed Nov 24 08:59:54 2021 +0100

    nptl: Do not set signal mask on second setjmp return [BZ #28607]

    __libc_signal_restore_set was in the wrong place: It also ran
    when setjmp returned the second time (after pthread_exit or
    pthread_cancel).  This is observable with blocked pending
    signals during thread exit.

    Fixes commit b3cae39dcbfa2432b3f3aa28854d8ac57f0de1b8
    ("nptl: Start new threads with all signals blocked [BZ #25098]").

    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-24  8:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-18 19:26 [Bug nptl/28607] New: Handles the masked signal when the thread exits gb.gwon at stackframe dot dev
2021-11-18 19:31 ` [Bug nptl/28607] Masked signals are delivered on thread exit fweimer at redhat dot com
2021-11-18 20:04 ` fweimer at redhat dot com
2021-11-22  8:48 ` schwab@linux-m68k.org
2021-11-24  8:21 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).