From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 7AC0D3858C78; Fri, 17 Feb 2023 10:59:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7AC0D3858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x535.google.com with SMTP id ez12so2788972edb.1; Fri, 17 Feb 2023 02:59:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=CAit3hFrCYVvCvBhzWiVSe73Q41c07wL26NJAJeDKMs=; b=nABMkYPwy3sLZvX2u6tfmNCKTWFeeBPUkB6RhSkV52Ip4mZ1jwkck2zTqITXrTttoP vfSTwRpw6GmcJHPAS6+q5ac6A+po8lDokEUx2SwLUzlT1l3q1jk9e6dQ/WtvG4N2nw/X 2TqlGewgHfCKSs3/DF0bCETJAdL3mFRjLdC1RQfBdRj+8UmLFdhHA+fXzX3MUuSDb4aG 2g6OIO8ZG4cgs5JTm5702LpsAxy5s3w7o9kTtGqb5AGH/+wKjN2aFAOJ48AWCxyJoZtm 9TCqO/VoSsEpsF8Q9gb+ckuLsu56QCYfMXYwpBVa0BRINhIhhhOc2RAvgaRjV1XtshtM +GNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CAit3hFrCYVvCvBhzWiVSe73Q41c07wL26NJAJeDKMs=; b=cdxjnuKj+wnUq4RAm6RArbDecWMCd5EEFVfNXqKiJ33x1i1a6NpGqk4BUqsdtdZs9F LomT10aEAOtiKQdFKKHy3F7YX9+nLwTZigSPLS98lSIDwUPfjmniuMEq/1uO8D3RPpiF K4Jtiiy9lvFyt3/o9hAoQzYe0RVrW9mS68Xpf/ShF2mSg+xjItLmZTx29H/sWeOdA6fE sPIaegp316AQJl7M5n2FA1pJ7Co3NH1/z3Tav09Vv5zQqgpKgv2adshZjLhAj+4SpOEK Gint8pZLyxvZGVLrG/z0U83apipfw+InYNv/8SXhR5FT/sjCnAQNpU9iaXj/LZxJQcEF mAOQ== X-Gm-Message-State: AO0yUKXu7ic1ZWRwKp9EQAoCfDQN+B4o5vO5sbb+qkinDLSZCNmITULy vd5HKzFoftZCyiNjmiz3myYC+9+sZH3tE26jj4o= X-Google-Smtp-Source: AK7set/jc41BqUy6pmXrDfe8zZ/y5QZ7JRN94FnRBTqus1NpccyZgty/fRE+rd2IwSqCkp0ob9wjXk/KNRdr/89u9ls= X-Received: by 2002:a05:6402:5484:b0:4ad:7c42:622 with SMTP id fg4-20020a056402548400b004ad7c420622mr1520437edb.4.1676631540005; Fri, 17 Feb 2023 02:59:00 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Fri, 17 Feb 2023 10:58:47 +0000 Message-ID: Subject: Re: [libstdc++] Use __gthread_join in jthread/95989 To: Alexandre Oliva Cc: gcc-patches , "libstdc++" , Bernd Edlinger Content-Type: multipart/alternative; boundary="0000000000005c85ce05f4e33302" X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,HTML_MESSAGE,KAM_NUMSUBJECT,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP 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: --0000000000005c85ce05f4e33302 Content-Type: text/plain; charset="UTF-8" On Fri, 17 Feb 2023, 06:40 Alexandre Oliva via Libstdc++, < libstdc++@gcc.gnu.org> wrote: > > Ref: https://gcc.gnu.org/pipermail/gcc-patches/2021-May/570617.html > > Bernd Edlinger reported that the 95989.cc > test fails without pthread_join at the end of main, Yes, but that doesn't mean we want to do that. but pthread_join > is no good for a test that doesn't require pthreads. > > This patch adds a __gthread_join call instead. > > Regstrapped on x86_64-linux-gnu. > Tested on arm-vxworks7 (gcc-12) and arm-eabi (trunk). Ok to install? > Nope, the test is correct, if it needs that there's a bug somewhere else. Papering over it in the test doesn't help. Each of test01, test02, and test03 creates a thread, joins it, and returns, which needs to work with no additional code. The change happens to "work" because it causes a non-weak reference to pthread_join, which otherwise doesn't get linked in from libpthread.a on ubuntu. The proper fix is to ensure the program has a non-weak reference to pthread_join without extra help (or use a recent glibc where it always works). > for libstdc++-v3/ChangeLog > > * testsuite/30_threads/jthread/95989.cc (main): Call > __gthread_join at the end. > --- > libstdc++-v3/testsuite/30_threads/jthread/95989.cc | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/libstdc++-v3/testsuite/30_threads/jthread/95989.cc > b/libstdc++-v3/testsuite/30_threads/jthread/95989.cc > index e98836d094531..407b52748438c 100644 > --- a/libstdc++-v3/testsuite/30_threads/jthread/95989.cc > +++ b/libstdc++-v3/testsuite/30_threads/jthread/95989.cc > @@ -52,4 +52,5 @@ main() > test01(); > test02(); > test03(); > + __gthread_join(0, NULL); > } > > -- > Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ > Free Software Activist GNU Toolchain Engineer > Disinformation flourishes because many people care deeply about injustice > but very few check the facts. Ask me about > --0000000000005c85ce05f4e33302--