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=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11142 invoked from network); 15 Mar 2022 20:36:16 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 15 Mar 2022 20:36:16 -0000 Received: (qmail 11836 invoked by uid 550); 15 Mar 2022 20:36:14 -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 11803 invoked from network); 15 Mar 2022 20:36:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=bK2HrOcYNF6FRqguBTOpqFJs8HlCO/nzijahj/5QsGo=; b=McZbBpvdR3QHpyNbuRJwgvJ7QNkBBP3oGHgfyTqdqAQKU6uFJFxRBPGq5yRkdgvaAd wt7goh8YuRTaqZnBlPQEr2PtGM+tXlpcZ6yawKzf3Dw3CKLoFgvraCAPFmP/OIFae7ld g90Y2vb9i8CTsDIg/5vxF7qYBCTUFRNgrVVEufLYouTncS+KUzLk2AegGBqATcVhDddY kLT13fXsy5WRZnmFMOARuZhofIXUpBI6S5PzNH4FiZ8lkgG/zdQEkT1JMCgzqg/w8Lxi IwPLV/DylT7eGlTRmyS48vFdBq2+KdaBnYBTfcWS6vMCrYP+fKD8U3g+EOMbdvV0+fj2 ScmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=bK2HrOcYNF6FRqguBTOpqFJs8HlCO/nzijahj/5QsGo=; b=z6MQY50Pq3JMQa5C06aGHRiZWjxSGbC/A901vtYOiZKKZMVnUg0FiQpb40wA/Y0Rt5 G7GFFgOMDzNJmebGRIwP3mw9gRyID0Ie/+ILgMgQ5A3U0UOW111NoNcNm6FsCaFCqyYz MCyYbnBM4O0E8TeRDv+wRXrT+I8RYhp2pTLN0PtdwqaO9nJ6sa+BkI++/j0kfnwevkwf /vxo5syLDmu6rhBhNt4Nct1DSE/CEJfNN5Mvi5w15tU1oCzGiFIxbQiyBaNFjcBS9aHM QeSWCIFIxYwtdxT+aYJ1Z7vtm2Hc259Nc5Q79okR/JQgPSaRBxgKq9YAsB4IoXqwfprk G/sw== X-Gm-Message-State: AOAM531R4cK4efN9uxHdxz4WWyItRdFoGVzw+opiYyOKCJHIgGRvYd6N yE/aYGsS5/Z0hp2c0sB0WQTiCIHKa9BzcsJTKvd8MhQG X-Google-Smtp-Source: ABdhPJwRFoPZKGYAh3YVTfCjQn9gBgQX6Viw7s//n80aK2fdO4sfDIt5aXlU92Ngpqn3j553i1Pjrz0NnEWmg4MUPkc= X-Received: by 2002:a05:6870:248c:b0:d7:19f3:a52c with SMTP id s12-20020a056870248c00b000d719f3a52cmr2285806oaq.149.1647376561095; Tue, 15 Mar 2022 13:36:01 -0700 (PDT) MIME-Version: 1.0 References: <20220311202151.GW7074@brightrain.aerifal.cx> <20220312150132.GX7074@brightrain.aerifal.cx> <20220314162303.GZ7074@brightrain.aerifal.cx> <20220315195056.GA8457@voyager> In-Reply-To: <20220315195056.GA8457@voyager> From: Gavin Howard Date: Tue, 15 Mar 2022 14:35:51 -0600 Message-ID: To: musl@lists.openwall.com Content-Type: multipart/alternative; boundary="000000000000bc484105da47be65" Subject: Re: [musl] Possible PEBKAC or Bug in musl Semaphores and/or Mutexes --000000000000bc484105da47be65 Content-Type: text/plain; charset="UTF-8" Well, I am a fool. I must have been too tired when I checked that. Gavin Howard On Tue, Mar 15, 2022, 13:51 Markus Wichmann wrote: > On Tue, Mar 15, 2022 at 12:55:38PM -0600, Gavin Howard wrote: > > I am pretty sure that this is the right place and that it is a bug in > > musl. > > Once more we find someone blaming the implementation for their own > mistake. From your repository: > > | y_Status > | y_strucon_rwlock_wrlock(y_strucon_rwlock* l) > | { > | y_ThreadData d = y_strucon_thread_os_get(); > | > | yc_assert(l != NULL, YC_ASSERT_NULL); > | yc_assert(d != NULL, YC_ASSERT_NULL); > | > | y_THREAD_TRYLOCK1(d); > | > | y_Status s = y_strucon_rwlock_os_rdlock(l); > | > | return s; > | } > > The mistake is in this function. See what the function is called and > what subfunction it calls? No wonder multiple threads can take the lock > simultaneously. > > Also, while reading I found a glaring mistake in y_THREAD_TRYUNLOCK1(), > which I shall leave as homework to the reader. > > Ciao, > Markus > --000000000000bc484105da47be65 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Well, I am a fool. I must have been too tired when I chec= ked that.

Gavin Howard

On= Tue, Mar 15, 2022, 13:51 Markus Wichmann <nullplan@gmx.net> wrote:
On Tue, Mar 15, 2022 at 12:55:38PM -0600, Gavin Howard wrote:
> I am pretty sure that this is the right place and that it is a bug in<= br> > musl.

Once more we find someone blaming the implementation for their own
mistake. From your repository:

| y_Status
| y_strucon_rwlock_wrlock(y_strucon_rwlock* l)
| {
|=C2=A0 =C2=A0 =C2=A0 =C2=A0y_ThreadData d =3D y_strucon_thread_os_get(); |
|=C2=A0 =C2=A0 =C2=A0 =C2=A0yc_assert(l !=3D NULL, YC_ASSERT_NULL);
|=C2=A0 =C2=A0 =C2=A0 =C2=A0yc_assert(d !=3D NULL, YC_ASSERT_NULL);
|
|=C2=A0 =C2=A0 =C2=A0 =C2=A0y_THREAD_TRYLOCK1(d);
|
|=C2=A0 =C2=A0 =C2=A0 =C2=A0y_Status s =3D y_strucon_rwlock_os_rdlock(l); |
|=C2=A0 =C2=A0 =C2=A0 =C2=A0return s;
| }

The mistake is in this function. See what the function is called and
what subfunction it calls? No wonder multiple threads can take the lock
simultaneously.

Also, while reading I found a glaring mistake in y_THREAD_TRYUNLOCK1(),
which I shall leave as homework to the reader.

Ciao,
Markus
--000000000000bc484105da47be65--