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

On 11/19/21 03:31, Florian Weimer wrote:
> * Gibeom Gwon:
> 
>> On 11/19/21 03:19, Florian Weimer wrote:
>>> * Gibeom Gwon:
>>>
>>>> On 11/19/21 03:08, Florian Weimer wrote:
>>>>> * Gibeom Gwon:
>>>>>
>>>>>> I am experiencing strange(unintended?) 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.
>>>>>>
>>>>>> It looks like glibc restores original signal mask at the end of the
>>>>>> thread. So I suspect this eventually triggers masked signal
>>>>>> handler. But I'm not sure it is intended or not.
>>>>> Which glibc version are you using?
>>>
>>>> Ah, I forgot to write the version. I'm using 2.33 and linux
>>>> distribution is Arch Linux.
>>> We had some issues with signals and thread exit in 2.34, but they
>>> are
>>> exclusive to that release and cannot happen in 2.33.  I can't reproduce
>>> the behavior you see with upstream 2.33, either.
>>> What's your kernel version?  I've tried 5.14.13 and 5.14.17.
>>> Thanks,
>>> Florian
>>>
>>
>> Kernel version is 5.15.2.
>>
>> Well, I accidently dropped sleep.c code sample. Here are the code
>> samples again. Sorry to bother you.
> 
> Ah, now the test makes a little bit more sense.  But I still get the
> expected output:
> 
> main thread: 140317152449984
> child thread: 140317150295616
> worker...
> worker...
> worker...
> worker...
> worker...
> worker...
> worker...
> worker...
> worker...
> worker...
> thread close
> sigchld: 140317152449984
> 
> So the signal gets delivered on the main thread, as expected.
> 
> Thanks,
> Florian
> 

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

Regards,
Gibeom Gwon

  reply	other threads:[~2021-11-18 18:35 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 [this message]
2021-11-18 19:10             ` Florian Weimer
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=93244325-1846-1c14-d225-f69f2a5b76e6@stackframe.dev \
    --to=gb.gwon@stackframe.dev \
    --cc=fweimer@redhat.com \
    --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).