From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 525FE3858D33; Mon, 6 Nov 2023 11:52:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 525FE3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 525FE3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.220.28 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699271530; cv=none; b=WZ027eWkCJFLR//ixHfWXBrvfE4Ly1HUD6ke8ZHEHfr83DWlJYSGVhoGpU+ITGPPbCjwP4VeLIyToqxJjwwYsi8tFI4ktAN/1WhCBJjGg5mUbFhrhh7qPr13hsOh8WbXVPZASnjyaONbH6+yLLgXHueolU+4nk9TPhEIomvsmzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699271530; c=relaxed/simple; bh=SKQp/biwyCXE5fxvYXTfEV1nl3J1bFfJ0MAd/pRB1do=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:MIME-Version; b=Qg8t8lz24Be2QMOdsh6fO+gPytf1vrQt8KYnFNqCYmWlwZ91hLXllySBPee/TdiRWL+vsPcPnxe8/prgz0H3PBt2i+Mju4l9ejtwdbBQstWvFOvXt9/iZimk/Os7gSGZNfoFlTKo1sWnkp7BJ7/yVr8KInYaiVNtC8K/WiEA3TI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 4A3CE21907; Mon, 6 Nov 2023 11:52:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1699271528; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=+6oKAlVXkJ4Hod0po6yEs/l+VD9FJaYBqcfwM2vcn+w=; b=canIUwes6QdCCVNjFivDnOv9au1H9xwmzg1w3Rpm7lVN3FtQ4G0nNhk6HIZMbOaZ8qRtUS vzNYRabqwViB5uAT6OaxlZoagOC4Va53rQy4t2lY+FF/Twu3QwZi/SFFJmOhfSn8vIc8tT C1142NZBiWFSOdBs/qEj16x90n5V8uU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1699271528; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=+6oKAlVXkJ4Hod0po6yEs/l+VD9FJaYBqcfwM2vcn+w=; b=tcpOdvFhXfhhywhBFPEofgbVKhtgoQOHL3Hw0Wt6wl0cxhNl8TclOze3KrKJbD+qhLbwMN zRFxOqaegZ1uPOCQ== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 0F68A2C2E6; Mon, 6 Nov 2023 11:52:08 +0000 (UTC) Date: Mon, 6 Nov 2023 11:52:08 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: libstdc++@gcc.gnu.org, jwakely@redhat.com Subject: [PATCH] libstdc++/112351 - deal with __gthread_once failure during locale init User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,MISSING_MID,SPF_HELO_NONE,SPF_PASS,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: Message-ID: <20231106115208.AoSI9X1_UM1GoydgNryott_EE055zCILVkGPXkj1pRo@z> 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; } -- 2.35.3