From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RDNS_DYNAMIC,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 dcvr.yhbt.net (Postfix) with ESMTPS id 1D4E31F8C6 for ; Mon, 30 Aug 2021 10:42:33 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ED9E13857412 for ; Mon, 30 Aug 2021 10:42:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED9E13857412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1630320152; bh=OmzdGh4YrbcDCMCC8AThk27mcTxZtVeg4GjwMv813IE=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=A5DpPLYRtWXT5rtdlcmwptHFAA7rshDwr9Drta2xFbUh85nFN0zgdLPIPGMQSUd1g QBbUiAXxJshGVErMPnPSCy0dA+bHo51jZyRfpzxM2kRMtFgx9uBnQ/VDh+rUyzudAq YgDeLUTCmgXb2R2zZhN1m58fOOaZ6A1OwdUYT8q4= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 130AB3858D35 for ; Mon, 30 Aug 2021 10:42:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 130AB3858D35 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-20-0weFJVVwMX6-0CzmSSAizA-1; Mon, 30 Aug 2021 06:42:11 -0400 X-MC-Unique: 0weFJVVwMX6-0CzmSSAizA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0158100E424; Mon, 30 Aug 2021 10:42:10 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.194.140]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D652A5C232; Mon, 30 Aug 2021 10:42:09 +0000 (UTC) To: Adhemerval Zanella Subject: Re: [PATCH v2 04/19] nptl: Do not use pthread set_tid_address as state synchronization (BZ #19951) References: <20210823195047.543237-1-adhemerval.zanella@linaro.org> <20210823195047.543237-5-adhemerval.zanella@linaro.org> <87y28o7ake.fsf@oldenburg.str.redhat.com> <1f026797-7be8-bf9d-323f-6ac7539752a1@linaro.org> <87zgt4454x.fsf@oldenburg.str.redhat.com> <8719cf82-e68a-402a-f019-174f5602251c@linaro.org> Date: Mon, 30 Aug 2021 12:42:07 +0200 In-Reply-To: <8719cf82-e68a-402a-f019-174f5602251c@linaro.org> (Adhemerval Zanella's message of "Thu, 26 Aug 2021 13:16:04 -0300") Message-ID: <87v93nqkn4.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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: , From: Florian Weimer via Libc-alpha Reply-To: Florian Weimer Cc: libc-alpha@sourceware.org Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" * Adhemerval Zanella: >>>>> diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c >>>>> index 08e5189ad6..763e32bc3e 100644 >>>>> --- a/nptl/pthread_create.c >>>>> +++ b/nptl/pthread_create.c >>>>> @@ -286,7 +286,7 @@ static int create_thread (struct pthread *pd, >>>>> const struct >>>>> @@ -351,13 +351,16 @@ start_thread (void *arg) >>>>> and free any resource prior return to the pthread_create caller. */ >>>>> setup_failed = pd->setup_failed == 1; >>>>> if (setup_failed) >>>>> - pd->joinid = NULL; >>>>> + pd->joinstate = THREAD_STATE_JOINABLE; >>>>> >>>>> /* And give it up right away. */ >>>>> lll_unlock (pd->lock, LLL_PRIVATE); >>>>> >>>>> if (setup_failed) >>>>> - goto out; >>>>> + { >>>>> + pd->tid = 0; >>>>> + goto out; >>>>> + } >>>>> } >>>> >>>> What's the advantage of setting pd->tid here and below in start_thread? >>> >>> We don't really need to clear the tid on setup_failed case in fact, since >>> in this case no pthread_t will be returned to caller. I remove it. >> >> What about the change in start_thread? >> >> The subsequent changes look at the tid member, but they could equally >> well look at joinstate, I think. > > My understanding it we still need to clear the tid member to avoid the > unintentional usage, since kernel will clear it anymore. For instance > on pthread_kill() (or any other usage), there is still an windows > where the joinstate test and the tid read might result in an invalid > value (either a tid reuse or an invalid value). It's more a matter of the final state. I think we should let the tid field be after the other changes went in. Thanks, Florian