From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id 8956F3870882; Fri, 12 Mar 2021 16:09:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8956F3870882 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4DxrP43Chxz1s1Vg; Fri, 12 Mar 2021 17:09:44 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4DxrP41ysTz1qr5K; Fri, 12 Mar 2021 17:09:44 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id MwqXSpKLSj2Y; Fri, 12 Mar 2021 17:09:41 +0100 (CET) X-Auth-Info: kAWlzMkEr7EKG2S8JhjCBb/3ASeg35NXSQl0TOeWQS8= Received: from jawa (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 12 Mar 2021 17:09:41 +0100 (CET) Date: Fri, 12 Mar 2021 17:09:34 +0100 From: Lukasz Majewski To: Joseph Myers , Adhemerval Zanella , Florian Weimer , DJ Delorie Cc: Paul Eggert , Alistair Francis , Arnd Bergmann , Alistair Francis , GNU C Library , Carlos O'Donell , Florian Weimer , Zack Weinberg , libc-help@sourceware.org Subject: Re: [RFC PATCH] tst: Add test for gai_suspend Message-ID: <20210312170934.2b29cc9d@jawa> In-Reply-To: <20210312154958.13842-1-lukma@denx.de> References: <20210312154958.13842-1-lukma@denx.de> Organization: denx.de X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/_CzR3E5WuevQVDCMHLnX/WQ"; protocol="application/pgp-signature" X-Spam-Status: No, score=-14.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Mar 2021 16:09:47 -0000 --Sig_/_CzR3E5WuevQVDCMHLnX/WQ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Dear Community, > --- > resolv/Makefile | 2 ++ > resolv/tst-gai_suspend.c | 53 > ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 > insertions(+) create mode 100644 resolv/tst-gai_suspend.c >=20 > diff --git a/resolv/Makefile b/resolv/Makefile > index 1047bb6ae5..e7e66fe903 100644 > --- a/resolv/Makefile > +++ b/resolv/Makefile > @@ -60,6 +60,7 @@ tests +=3D \ > tst-resolv-res_init-multi \ > tst-resolv-search \ > tst-resolv-trailing \ > + tst-gai_suspend \ > =20 > # This test calls __res_context_send directly, which is not exported > # from libresolv. > @@ -209,3 +210,4 @@ $(objpfx)tst-ns_name_compress: > $(objpfx)libresolv.so $(objpfx)tst-ns_name_pton: $(objpfx)libresolv.so > $(objpfx)tst-res_hnok: $(objpfx)libresolv.so > $(objpfx)tst-p_secstodate: $(objpfx)libresolv.so > +$(objpfx)tst-gai_suspend: $(objpfx)libanl.so > diff --git a/resolv/tst-gai_suspend.c b/resolv/tst-gai_suspend.c > new file mode 100644 > index 0000000000..bbafd13fc4 > --- /dev/null > +++ b/resolv/tst-gai_suspend.c > @@ -0,0 +1,53 @@ > +/* Test for gai_suspend timeout > + Copyright (C) 2021 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be > useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +static int > +do_test (void) > +{ > + struct timespec ts; > + xclock_gettime (CLOCK_REALTIME, &ts); > + struct timespec timeout =3D make_timespec (1, 0); > + ts =3D timespec_add (ts, timeout); > + > + /* Ignore gaicb content - just wait for timeout. */ > + struct addrinfo result; > + > + struct gaicb gai =3D { "foo.baz", "0", NULL, &result }; > + const struct gaicb * const gai_s[] =3D { &gai }; > + struct gaicb *gai_p =3D &gai; > + > + int ret =3D getaddrinfo_a (GAI_NOWAIT, &gai_p, 1, NULL); > + if (ret !=3D 0) > + FAIL_EXIT1 ("getaddrinfo_a failed: %m\n"); > + > + ret =3D gai_suspend (gai_s, 1, &timeout); > + TEST_COMPARE (ret, EAI_AGAIN); > + TEST_TIMESPEC_NOW_OR_AFTER (CLOCK_REALTIME, ts); > + > + return 0; > +} > + > +#include I'm a bit puzzled with the above gai_suspend() test. The idea for Y2038 test is to check if one can timeout when passed crafted struct gaicb causes the gai_suspend() to exit with timeout. This approach is similar to one from tst-ppoll.c 1. When I do run it by hand on the remove machine (from glibc test suite): -------------------------------------------------- rm -rf ./resolv/* make PARALLELMFLAGS=3D"-j8" test-wrapper=3D'/home/lukma/work/yocto/y2038/build/workspace/sources/y2038-= glibc/scripts/cross-test-ssh.sh --allow-time-setting root@192.168.7.2' subdirs=3Dresolv check I do see the following error: ----------------------------- cat ./resolv/tst-gai_suspend.out Didn't expect signal from child: got `Segmentation fault' This is strange, as I've passed NULL to getaddrinfo_a as the last parameter, which causes passing no signals to program running it. What am I missing here? Has the test setup any strict policy to handle LWPs ? 2. On the VM (armv7): gai_suspend.c test program: --------------------------- #define _GNU_SOURCE #include #include #include int main (int argc, char **argv) { struct timespec ts, timeout, now; clock_gettime (CLOCK_REALTIME, &ts); timeout.tv_sec =3D ts.tv_sec + 3; timeout.tv_nsec =3D ts.tv_nsec; struct addrinfo result; struct gaicb gai =3D { "foo.baz", "0", NULL, &result }; const struct gaicb * const gai_s[] =3D { &gai }; struct gaicb *gai_p =3D &gai; int ret =3D getaddrinfo_a (GAI_NOWAIT, &gai_p, 1, NULL); if (ret !=3D 0) printf("getaddrinfo_a error"); ret =3D gai_suspend (gai_s, 1, &timeout); // According to man getaddrinfo_s I shall receive ret =3D=3D -3 // when conversion from name to IP credentials is performed if (ret !=3D 0) printf("gai_suspend error"); clock_gettime (CLOCK_REALTIME, &now); printf("gai_suspend seconds diff: %llu\n", now.tv_sec - ts.tv_sec); return 0; } gcc -Wall -ggdb -D_TIME_BITS=3D64 -D_FILE_OFFSET_BITS=3D64 -I/opt/include \ -I/opt/usr/include -L/opt/usr/lib -Wl,-rpath=3D/opt/lib \ -Wl,--dynamic-linker=3D/opt/lib/ld-linux.so.2 gai_suspend.c -o gs -lanl \ -lpthread -static The above line has some manual adjustments for linker, but this works for other syscalls for some long time now - more info [1]. In this case the program quits without any issues with threads, but the output and behavior of gai_suspend is not as expected (according at least to the manual [2]). The return code from gai_suspend shall be EAI_AGAIN and the result struct has some garbage in it. The question(s): =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 1. Why I do experience thread error in glibc test suite? 2. Is the code for gai_suspend testing wrong (not much reference in glibc), or do we have a bug in the the implementation? Thanks in advance for any help/hints. Links: [1] - https://github.com/lmajewski/meta-y2038/ [2] - https://linux.die.net/man/3/gai_suspend Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de --Sig_/_CzR3E5WuevQVDCMHLnX/WQ Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAmBLkj4ACgkQAR8vZIA0 zr0yRgf+IkaiU871PXgp40WHhrjtQz3u9deepJfgbhbHLRtx73b43y7Fr9WJXmYJ Bn+Wxu7K7XJf4ZG1x8G9lvxFukoI4e0E37DkisHqeHQIJf+pjWpJPbrnvvyzj6X7 8p70w52fSLNfWhFX92dAZZUKHwVdM/uwrHFEDNOhdMP/RXJAxLFNqmRRyZVAWY/2 UthQrXLYnAzcY9C/robapp4+6YgXUt57x7zFXddTOsuq0Xyz852Vid+VosO48UL1 m+oVhQl79tiGvbFm0zmFtA9ym7OcumXBdycvTbY/3o70l3oF9bczOse8uZTJOW4E 85dBvaPBwTeE2rg01nxL0AlyeWtf+g== =pLSh -----END PGP SIGNATURE----- --Sig_/_CzR3E5WuevQVDCMHLnX/WQ--