From patchwork Mon Feb 14 18:29:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1592749 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JyCT85G8Gz9s5B for ; Tue, 15 Feb 2022 05:30:36 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 51A1D3858413 for ; Mon, 14 Feb 2022 18:30:34 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1]) by sourceware.org (Postfix) with ESMTPS id 10A7B3857C50 for ; Mon, 14 Feb 2022 18:29:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 10A7B3857C50 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 310785D5; Mon, 14 Feb 2022 19:29:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xglW8CUHPmt3; Mon, 14 Feb 2022 19:29:41 +0100 (CET) Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49]) by hera.aquilenet.fr (Postfix) with ESMTPSA id BFA92388; Mon, 14 Feb 2022 19:29:41 +0100 (CET) Received: from samy by begin with local (Exim 4.95) (envelope-from ) id 1nJg6X-00CIU4-C9; Mon, 14 Feb 2022 19:29:41 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd,commited] htl: Fix initializing the key lock Date: Mon, 14 Feb 2022 19:29:40 +0100 Message-Id: <20220214182940.2930977-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spamd-Bar: ++++ X-Rspamd-Server: hera Authentication-Results: hera.aquilenet.fr; none X-Rspamd-Queue-Id: 310785D5 X-Spamd-Result: default: False [4.90 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; MID_CONTAINS_FROM(1.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[] X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE 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-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: , Cc: commit-hurd@gnu.org Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The static pthread_once_t in the pt-key.h header was creating one pthread_once_t per includer. We have to use a shared common pthread_once_t instead. --- sysdeps/htl/pt-key-create.c | 1 + sysdeps/htl/pt-key.h | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sysdeps/htl/pt-key-create.c b/sysdeps/htl/pt-key-create.c index ca4908c55c..f8dc5ac0c5 100644 --- a/sysdeps/htl/pt-key-create.c +++ b/sysdeps/htl/pt-key-create.c @@ -24,6 +24,7 @@ #include pthread_mutex_t __pthread_key_lock; +pthread_once_t __pthread_key_once = PTHREAD_ONCE_INIT; void (**__pthread_key_destructors) (void *arg); int __pthread_key_size; diff --git a/sysdeps/htl/pt-key.h b/sysdeps/htl/pt-key.h index 34c12d51ab..ef652ecc6f 100644 --- a/sysdeps/htl/pt-key.h +++ b/sysdeps/htl/pt-key.h @@ -47,14 +47,15 @@ extern int __pthread_key_invalid_count; /* Protects the above variables. This must be a recursive lock: the destructors may call pthread_key_delete. */ extern pthread_mutex_t __pthread_key_lock; + +/* Protects the initialization of the mutex above. */ +extern pthread_once_t __pthread_key_once; #include static inline void __pthread_key_lock_ready (void) { - static pthread_once_t o = PTHREAD_ONCE_INIT; - void do_init (void) { int err; @@ -73,5 +74,5 @@ __pthread_key_lock_ready (void) assert_perror (err); } - __pthread_once (&o, do_init); + __pthread_once (&__pthread_key_once, do_init); }