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.133.124]) by sourceware.org (Postfix) with ESMTPS id DB008385840F for ; Mon, 6 Nov 2023 12:16:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB008385840F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DB008385840F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699272979; cv=none; b=g0MyJMzrs9IZ/+TLY9fx6srx+J+A0CjkJyXY7llpMkpZe83UDMOqkUhUQwHiYSgewX8cghk1t4ALrySGkND5Uf8bqwYjeR7jGChCTqjRxYyUcH3+1LP2jI3bhY0pKaPgyloKxt8/ti1N8KmCI2Mqo8T01hZLH9F7ZBrFa9T1LGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699272979; c=relaxed/simple; bh=+2wDkeV/+ACfX7woMu78g215BwD1yHzhuSr9u0yvxM0=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=V4IXWQX4bP0JmYCyDz4Sqr7kv6gS4P4b/kqg46XIA/CJc3NsQAgzqvIpHEvkjm/RoxcmsNwmAi155uN0ODt3JUlvbeUXJwulIKCuH/v3bhSBPnLbz+ycdQSZ6j1YlAK/TCpy909j/HsJBWzwbWmVCQAaHZdIBNNbTUp1BuwOkTU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699272977; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=IbwXlB5ep8BFwn6w0p3QncS+YOkFkbHK6eHEp9fTpPI=; b=AU6v9ptxEAJMgN+mi1QKFcjW/U+fDTyn42TbhVKGJ0Gtp9xsxyJOiFL5YRuYu9Y0LCNsOO h1HO2kzqUmLqEoX1eM5hccRuaPUkeP84l2XCPECY8GIsfC6YZnBNC1mLqYcR3aOMzaeZPs HzpsLJ6vUyr62YIE3mFAF8uP7/al8ac= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-22-ahIHahXSP8qHwl_PLCf2tQ-1; Mon, 06 Nov 2023 07:16:16 -0500 X-MC-Unique: ahIHahXSP8qHwl_PLCf2tQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D4F0A101A52D; Mon, 6 Nov 2023 12:16:15 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 973F3492BFA; Mon, 6 Nov 2023 12:16:15 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3A6CGDle1798438 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 6 Nov 2023 13:16:13 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3A6CGCSM1798437; Mon, 6 Nov 2023 13:16:12 +0100 Date: Mon, 6 Nov 2023 13:16:12 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, jwakely@redhat.com Subject: Re: [PATCH] libstdc++/112351 - deal with __gthread_once failure during locale init Message-ID: Reply-To: Jakub Jelinek References: <20231106115212.6DCC23858C00@sourceware.org> MIME-Version: 1.0 In-Reply-To: <20231106115212.6DCC23858C00@sourceware.org> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-9.4 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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Nov 06, 2023 at 11:52:08AM +0000, Richard Biener wrote: > The following makes the C++98 locale init path follow the way the > C++11 performs initialization. This way we deal with pthread_once > failing, falling back to non-threadsafe initialization which, given we > initialize from the library, should be serialized by the dynamic > loader already. > > Bootstrapped and tested on x86_64-unknown-linux-gnu, OK for trunk? > And GCC 13 branch? > > Thanks, > Richard. > > PR libstdc++/112351 > libstdc++-v3/ > * src/c++98/locale.cc (locale::facet::_S_get_c_locale): > Always perform non-threadsafe init when threadsafe init > failed. > --- > libstdc++-v3/src/c++98/locale.cc | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/libstdc++-v3/src/c++98/locale.cc b/libstdc++-v3/src/c++98/locale.cc > index d308140bab7..e9bec1db3b6 100644 > --- a/libstdc++-v3/src/c++98/locale.cc > +++ b/libstdc++-v3/src/c++98/locale.cc > @@ -216,12 +216,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > #ifdef __GTHREADS > if (__gthread_active_p()) > __gthread_once(&_S_once, _S_initialize_once); > - else > #endif > - { > - if (!_S_c_locale) > - _S_initialize_once(); > - } > + if (__builtin_expect (!_S_c_locale, 0)) > + _S_initialize_once(); > return _S_c_locale; Wouldn't it be better to just test __gthread_once return value #ifdef __THREADS if ((!__gthread_active_p() || __gthread_once(&_S_once, _S_initialize_once))) #endif if (!_S_c_locale) _S_initialize_once(); ? Jakub