From patchwork Tue May 19 10:45:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 39316 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0E1793957055; Tue, 19 May 2020 10:45:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E1793957055 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1589885154; bh=NqDBn4rYEFVyQnA23V95Zb5tqByiyykW4Pq37zcywPQ=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WB3YqB8ClhiJwKwiGyD6D96cWI7tePE61jLfAmD6rzoF1NakPNLtytwtmcFIdsfrL s8aZNF1KNmT63x/Ecdl9Loi+nXQ588bal73PDfC2hEhNKDNKvz0vmNP/eEJb8Ir4mk dsIoLEJ+Nk6DPiH+vSTraO2z9ztfhta0hfdc2avc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 70835393F841 for ; Tue, 19 May 2020 10:45:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 70835393F841 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-410-fKdDLRhUOfuVnbtB20fl2A-1; Tue, 19 May 2020 06:45:50 -0400 X-MC-Unique: fKdDLRhUOfuVnbtB20fl2A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58B27100CCD4 for ; Tue, 19 May 2020 10:45:49 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-113-18.ams2.redhat.com [10.36.113.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CFFDD6E9FD for ; Tue, 19 May 2020 10:45:48 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 19/19] Linux: Use __pthread_attr_setsigmask_internal for timer helper thread In-Reply-To: References: Message-Id: Date: Tue, 19 May 2020 12:45:47 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.1 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_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" timer_create needs to create threads with all signals blocked, including SIGTIMER (which happens to equal SIGCANCEL). Add a new internal interface which provides an explicit way to achieve that. Fixes commit b3cae39dcbfa2432b3f3aa28854d8ac57f0de1b8 ("nptl: Start new threads with all signals blocked [BZ #25098]"). Reviewed-by: Carlos O'Donell --- sysdeps/unix/sysv/linux/timer_routines.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sysdeps/unix/sysv/linux/timer_routines.c b/sysdeps/unix/sysv/linux/timer_routines.c index 63083f6f91..86fad2a2c0 100644 --- a/sysdeps/unix/sysv/linux/timer_routines.c +++ b/sysdeps/unix/sysv/linux/timer_routines.c @@ -136,23 +136,24 @@ __start_helper_thread (void) (void) pthread_attr_init (&attr); (void) pthread_attr_setstacksize (&attr, __pthread_get_minstack (&attr)); - /* Block all signals in the helper thread but SIGSETXID. To do this - thoroughly we temporarily have to block all signals here. The - helper can lose wakeups if SIGTIMER is not blocked throughout. */ + /* Block all signals in the helper thread but SIGSETXID. */ sigset_t ss; - __libc_signal_block_app (&ss); - __libc_signal_block_sigtimer (NULL); + __sigfillset (&ss); + __sigdelset (&ss, SIGSETXID); + int res = __pthread_attr_setsigmask_internal (&attr, &ss); + if (res != 0) + { + pthread_attr_destroy (&attr); + return; + } /* Create the helper thread for this timer. */ pthread_t th; - int res = pthread_create (&th, &attr, timer_helper_thread, NULL); + res = pthread_create (&th, &attr, timer_helper_thread, NULL); if (res == 0) /* We managed to start the helper thread. */ __helper_tid = ((struct pthread *) th)->tid; - /* Restore the signal mask. */ - __libc_signal_restore_set (&ss); - /* No need for the attribute anymore. */ (void) pthread_attr_destroy (&attr);