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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id 0038E3858014 for ; Thu, 18 Nov 2021 19:11:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0038E3858014 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-603-8ZHL2qrQM_-ESD9NkKBz1Q-1; Thu, 18 Nov 2021 14:11:00 -0500 X-MC-Unique: 8ZHL2qrQM_-ESD9NkKBz1Q-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 21CCE19253C3; Thu, 18 Nov 2021 19:10:59 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.131]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D92425C1D5; Thu, 18 Nov 2021 19:10:57 +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> <87r1bde2o5.fsf@oldenburg.str.redhat.com> <93244325-1846-1c14-d225-f69f2a5b76e6@stackframe.dev> Date: Thu, 18 Nov 2021 20:10:55 +0100 In-Reply-To: <93244325-1846-1c14-d225-f69f2a5b76e6@stackframe.dev> (Gibeom Gwon's message of "Fri, 19 Nov 2021 03:35:40 +0900") Message-ID: <87ilwpe0u8.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=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham 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 19:11:10 -0000 * 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? 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