From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 499 invoked from network); 11 Feb 2023 17:50:31 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 11 Feb 2023 17:50:31 -0000 Received: (qmail 29734 invoked by uid 550); 11 Feb 2023 17:50:29 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 29702 invoked from network); 11 Feb 2023 17:50:28 -0000 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 0A7B640737BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1676137816; bh=WaOhBDT449FcyNqnQrTDalg3GG2KQ+/OHy8RjHFD6Aw=; h=Date:From:To:Subject:In-Reply-To:References:From; b=ZSeiOrKrN7fThYxKLypt8NKqXntddAVQUjQD86QZVISJuNGJexB66fvRpjJ2gPeP7 JCpN/4K0PSo7s2/ZiiiIduOhRrF8VYr2ChTo8UzjqHkJtdrEHkUH7Q0c7XVrmKyF3p 8Fp8JtCZ3qi3Wjt81oOLHhM1Ljs8ZWpObBSY3cSk= MIME-Version: 1.0 Date: Sat, 11 Feb 2023 20:50:15 +0300 From: Alexey Izbyshev To: musl@lists.openwall.com In-Reply-To: <20230211171338.GD1903@voyager> References: <20221109104613.48062-1-izbyshev@ispras.ru> <20221214022618.GB15716@brightrain.aerifal.cx> <1a0289c15879bef6d538c0066f58545c@ispras.ru> <20230210162957.GB4163@brightrain.aerifal.cx> <63c0897d647936c946268f5a967a5e4d@ispras.ru> <20230211150603.GI4163@brightrain.aerifal.cx> <20230211171338.GD1903@voyager> User-Agent: Roundcube Webmail/1.4.4 Message-ID: <2da3840a9345c0a810e9d93ab4f6bca7@ispras.ru> X-Sender: izbyshev@ispras.ru Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [musl] [PATCH] mq_notify: fix close/recv race on failure path On 2023-02-11 20:13, Markus Wichmann wrote: > On Sat, Feb 11, 2023 at 10:06:03AM -0500, Rich Felker wrote: >> --- a/src/thread/pthread_detach.c >> +++ b/src/thread/pthread_detach.c >> @@ -5,8 +5,12 @@ static int __pthread_detach(pthread_t t) >> { >> /* If the cas fails, detach state is either already-detached >> * or exiting/exited, and pthread_join will trap or cleanup. */ >> - if (a_cas(&t->detach_state, DT_JOINABLE, DT_DETACHED) != >> DT_JOINABLE) >> + if (a_cas(&t->detach_state, DT_JOINABLE, DT_DETACHED) != >> DT_JOINABLE) { >> + int cs; >> + __pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); >> return __pthread_join(t, 0); > ^^^^^^ I think you forgot to rework this. >> + __pthread_setcancelstate(cs, 0); >> + } >> return 0; >> } >> > > I see no other obvious missteps, though. > Same here, apart from this and misspelled "pthred_detach" in the commit message, the patches look good to me. Regarding the POSIX requirement to run sigev_notify_function in the context of a detached thread, while it's possible to observe the wrong detachstate for a short while via pthread_getattr_np after these patches, I'm not sure there is a standard way to do that. Even if it exists, this minor issue may be not worth caring about. Thanks, Alexey