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.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3298 invoked from network); 27 Apr 2021 20:56:11 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 27 Apr 2021 20:56:11 -0000 Received: (qmail 26564 invoked by uid 550); 27 Apr 2021 20:56:08 -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 26543 invoked from network); 27 Apr 2021 20:56:07 -0000 Date: Tue, 27 Apr 2021 22:55:55 +0200 From: Szabolcs Nagy To: =?utf-8?B?w4lyaWNv?= Nogueira , Matus Kysel Cc: musl@lists.openwall.com Message-ID: <20210427205555.GL2799122@port70.net> Mail-Followup-To: =?utf-8?B?w4lyaWNv?= Nogueira , Matus Kysel , musl@lists.openwall.com References: <611bff39248143248ce9edd6762fb804@tachyum.com> <20210427195550.GK2799122@port70.net> <5ff92ac3-a5e0-b97e-4205-f5d62c98b389@disroot.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <5ff92ac3-a5e0-b97e-4205-f5d62c98b389@disroot.org> Subject: Re: [musl] Re: libc-test issue with sem_close * =C3=89rico Nogueira [2021-04-27 17:49:45 -0300]: > Em 27/04/2021 17:33, =C3=89rico Nogueira escreveu: > > Em 27/04/2021 16:55, Szabolcs Nagy escreveu: > > > * Matus Kysel [2021-04-26 09:49:35 +0000]: > > > > Hi Szabolcs, > > > >=20 > > > > I am using your library as part of my validation suite and > > > > recently I have updated it to latest master, but the sem_close > > > > test is not buildable for me as it is missing fcntl.h header. I > > > > have attached possible fix, because I did not found how to > > > > contribute to you repo. > > >=20 > > > ccing musl, libc-test is mostly discussed there. > > >=20 > > > posix says > > >=20 > > > "Inclusion of the header may make visible symbols > > > defined in the and headers." > > >=20 > > > https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/semaphore.h= =2Ehtml > > >=20 > > >=20 > > > which sounds optional, not guaranteed visibility of O_ open flags in > > > semaphore.h, but sem_open is expected to be usable with only semaphor= e.h > > >=20 > > > https://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_open.h= tml > > >=20 > > > i'm not sure what is the strict standard requirement here, without > > > clarification i consider it a libc header issue if an api is not usab= le > > > with just the header where it is declared. > > >=20 > >=20 > > The linux man page for sem_open(3) says including is necessary > > for the flags, and indeed the test fails to build on glibc. > >=20 > > =C2=A0The oflag argument specifies flags that control the operation of= the > > =C2=A0call.=C2=A0 (Definitions of the flags values can be obtained by = including > > =C2=A0.) > >=20 > > sem_open(name, 0) works without , otherwise it's necessary. > >=20 > > Taking advantage of the fact that the regressions/sem_close-unmap test > > has been brought up, it has some interesting results: > >=20 > > On glibc 2.32: > > - works with dynamic linking > > - segfaults in sem_open() with static linking (might be something wrong > > with the build?) > >=20 > > On musl 1.2.2: > > - segfaults most of the time (always?) >=20 > My mistake, I was on 1.2.1. >=20 > >=20 > > On musl master (aad50fcd791e009961621ddfbe3d4c245fd689a3): > > - completes successfully most of the time, segfaults ever so often > > (which would lead me to assume the fix from > > f70375df85d26235a45e74559afd69be59e5ff99 wasn't enough) >=20 > The sem_create() calls can sometimes fail here with EINVAL because sem_op= en > is being called with the wrong number of arguments. Included patch to fix > it. thanks for looking into this. based on this i applied both patches (include fcntl.h and the argument fix). > From bb113fe0b0e209681b1c0d6317440bf64f57ea80 Mon Sep 17 00:00:00 2001 > From: =3D?UTF-8?q?=3DC3=3D89rico=3D20Nogueira?=3D > Date: Tue, 27 Apr 2021 17:46:17 -0300 > Subject: [PATCH] fix sem_close regression test >=20 > sem_close with O_CREAT takes 4 parameters, not 3. The last parameter, > the initial value for the semaphore, had an arbitrary value from > whatever was on the stack, and lead to spurious failures with EINVAL > when it happened to be greater than SEM_VALUE_MAX. Since there isn't > error checking in this test, this lead to a segfault in the first > sem_post call. > --- > src/regression/sem_close-unmap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/src/regression/sem_close-unmap.c b/src/regression/sem_close-= unmap.c > index f1e51d9..73c53e3 100644 > --- a/src/regression/sem_close-unmap.c > +++ b/src/regression/sem_close-unmap.c > @@ -8,7 +8,7 @@ int main() > char buf[] =3D "mysemXXXXXX"; > if (!mktemp(buf)) return 1; > // open twice > - sem_t *sem =3D sem_open(buf, O_CREAT|O_EXCL, 0600); > + sem_t *sem =3D sem_open(buf, O_CREAT|O_EXCL, 0600, 0); > sem_open(buf, 0); > sem_unlink(buf); > // close once > --=20 > 2.31.1 >=20