From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id F417A3857439 for ; Thu, 18 Nov 2021 18:31:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F417A3857439 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-207-CrB41zE8NZex4OXqP8PXgQ-1; Thu, 18 Nov 2021 13:31:26 -0500 X-MC-Unique: CrB41zE8NZex4OXqP8PXgQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 60D40DF8A3; Thu, 18 Nov 2021 18:31:25 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.131]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8632F5C3E0; Thu, 18 Nov 2021 18:31:24 +0000 (UTC) From: Florian Weimer To: Gibeom Gwon Cc: libc-help@sourceware.org Subject: Re: Handles the masked signal when the thread exits References: <2fb82128-a9da-e7f5-8062-f7e72b1561db@stackframe.dev> <8735ntfi9y.fsf@oldenburg.str.redhat.com> <7f3882b1-1c09-83af-40b9-979a400f097e@stackframe.dev> <87v90pe38f.fsf@oldenburg.str.redhat.com> <6ee2a107-c4da-eba7-64ed-8e06af7a961a@stackframe.dev> Date: Thu, 18 Nov 2021 19:31:22 +0100 In-Reply-To: <6ee2a107-c4da-eba7-64ed-8e06af7a961a@stackframe.dev> (Gibeom Gwon's message of "Fri, 19 Nov 2021 03:25:29 +0900") Message-ID: <87r1bde2o5.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, LONGWORDS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Nov 2021 18:31:31 -0000 * 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