public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Gibeom Gwon <gb.gwon@stackframe.dev>
Cc: libc-help@sourceware.org
Subject: Re: Handles the masked signal when the thread exits
Date: Thu, 18 Nov 2021 20:10:55 +0100	[thread overview]
Message-ID: <87ilwpe0u8.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <93244325-1846-1c14-d225-f69f2a5b76e6@stackframe.dev> (Gibeom Gwon's message of "Fri, 19 Nov 2021 03:35:40 +0900")

* Gibeom Gwon:

> I hit Ctrl+C in the middle of running signal program. You can see
> ^C and sigint:.. printed in my result.

I see it now.  It's a real bug.  It only happens with cancellation.

Would yo umind filing a bug here?

  <https://sourceware.org/bugzilla/enter_bug.cgi?product=glibc&component=nptl>

The fix should look something like this:

diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index d6ea43a754..bad9eeb52f 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -406,8 +406,6 @@ start_thread (void *arg)
   unwind_buf.priv.data.prev = NULL;
   unwind_buf.priv.data.cleanup = NULL;
 
-  __libc_signal_restore_set (&pd->sigmask);
-
   /* Allow setxid from now onwards.  */
   if (__glibc_unlikely (atomic_exchange_acq (&pd->setxid_futex, 0) == -2))
     futex_wake (&pd->setxid_futex, 1, FUTEX_PRIVATE);
@@ -417,6 +415,8 @@ start_thread (void *arg)
       /* Store the new cleanup handler info.  */
       THREAD_SETMEM (pd, cleanup_jmp_buf, &unwind_buf);
 
+      __libc_signal_restore_set (&pd->sigmask);
+
       LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg);
 
       /* Run the code the user provided.  */

Thanks,
Florian


  reply	other threads:[~2021-11-18 19:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18 18:07 Gibeom Gwon
2021-11-18 18:08 ` Florian Weimer
2021-11-18 18:11   ` Gibeom Gwon
2021-11-18 18:19     ` Florian Weimer
2021-11-18 18:25       ` Gibeom Gwon
2021-11-18 18:31         ` Florian Weimer
2021-11-18 18:35           ` Gibeom Gwon
2021-11-18 19:10             ` Florian Weimer [this message]
2021-11-18 19:29               ` Gibeom Gwon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ilwpe0u8.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=gb.gwon@stackframe.dev \
    --cc=libc-help@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).