From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.web.de (mout.web.de [212.227.17.11]) by sourceware.org (Postfix) with ESMTPS id B917C3857C48 for ; Sun, 14 Feb 2021 12:18:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B917C3857C48 X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from [192.168.2.103] ([84.143.151.159]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MKJ7S-1lCuWK0HFW-001gkw for ; Sun, 14 Feb 2021 13:18:42 +0100 Subject: Re: (stat(...) == -1 || faccessat(...) == -1) && errno == EINTR ?!?? From: Tobias Bading To: libc-help@sourceware.org References: Message-ID: Date: Sun, 14 Feb 2021 13:18:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------79751418E9043EBD02430DD5" Content-Language: en-US X-Provags-ID: V03:K1:H5wBniaoUrADm4XFBjWA42v69Xn0xi3lQy54a6mVxdvfW7Sy1A7 K9MyRRcj3SpYNrCOX9OVcg0SOJwkjD30Hu+XRWXPAtRvNTX2lfYYUSI2HFoLurm892y7oFZ O0a8SDfi6JDIEO5FUQQWcbua0Oq6j0gF+44E8STeGDXGsnhcU6C6TUffcjSMbXhfQqIY6iV R1w8EibRxj8BwqvXeP6uw== X-UI-Out-Filterresults: notjunk:1;V03:K0:MfcW1+XjWWQ=:nqG6saMvatbOBP5QkB6YFI Pl3URESY4b87sjWU6QDxslxcsON10BORFq9+BrSmjfKKC7+dB0sAzp3LnkxpqFYrcnadeaVOM SlKQ8A7adKBejr8LxWcuxhwSnkEPNxuSP8APz0Tw2Py40k5h7p5vkCoct1y41jBSwZo4DC43W i3+z7eNuh3yv+3q1nbPj0X8tIYR3o+kyZ5DWqIyb55/hn76WAO8zKRosk5IBuu1+79ndISs4h YH9G9Pvc9mK5Ub4tPVjEV051/r9f3X0E3/ezmGdnoaLycf+ZpQOXGYFp3Y6JenGTleXjEv8SC herTV8G88B47UzoVAlbeB0SHPqh+9iML13tYxgbmKj8d7n+S5vmSf9+7nqPGKKVbeY2v69QoB Wfl8mauDn2Lps/y/s1mgcL+h3+nyjiO7e2dlSzMvpY3EweVphsVPTwf4hv5s9Cp568+bQh5cY M0GXtoUYzkBWQjEYNQnxM6A8ozv5Kb1KLG9zHyuNPLjyUu4Wx/XYMVyw+lgqiC1GXG5ijpLzO m87sozVRO5sdg2A2J6wTv+vB+QpKDGuc70HisetC1cDWypkRhBzuQ2mLVdtkulDtl+n15fNSR ZUdqhBXiKPQxaliL9wttf7e4EeVU/lbQRRyViycu48JdBxAwFPGzKLdPyMqu4QPXXAE2VtRxG +GEuWKieU4G1S+RTa3lTH0tF8r6mbkArfUWoR+zjJerZ4J6QreUAwPNgsf81SzY9Qrbc8pNSc arynWDbr8S315XOP7W9wv8MUhyv0Glnvgw1zQZIbBmE9xXXsB8/iWyVHdSvMm4eWB2dkOiehV gf+3tHsHtFHUkPnarzfXg5bZQJbGeDY2afTkprVuA5m/qaV6GdfGI/5VzfxmuoQNSU2Ms/6HU JF0tJ8gXttVX7ELaqhGQ== X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, LOTS_OF_MONEY, NICE_REPLY_A, PLING_QUERY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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: Sun, 14 Feb 2021 12:18:45 -0000 This is a multi-part message in MIME format. --------------79751418E9043EBD02430DD5 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Hello again. I've been able to reproduce the problem with the attached program. With SIGALRMs firing 10 times per second, I get maybe a dozen "handler called" lines before stat() or faccessat() fails with errno EINTR. When I increase the rate to 50 SIGALRMs per second, the very first stat() fails in every test run. Specifying SA_RESTART in sigaction() has no effect. Unfortunately, I don't have any other network shares available at the moment to test whether only CIFS through VPN is affected, or the problem would occur with e.g. NFS or CIFS without a VPN as well. Tobias =2D-- On 14.02.21 12:13, Tobias Bading wrote: > Hi. > > A few days ago I encountered strange problems at home while using GNU > Emacs on GNU/Linux with Windows SMB shares in the office automounted > through the company's VPN. > > Details and my current findings on the Emacs devel mailing list: > https://lists.gnu.org/archive/html/emacs-devel/2021-02/msg00835.html. > > TL;DR: > Emacs' stat() and faccessat() calls sometimes return -1 and set errno > to EINTR (according to strace). Most of the time the interruption > seems to come from a SIGIO, but at least once a SIGCHLD was in the mix > as well. > > The behavior of returning with errno =3D=3D EINTR seems to be new and/or > some kind of bug, because otherwise Emacs would handle that case with > TEMP_FAILURE_RETRY() or something to that effect, right? I've used > pretty much the same Emacs in the office (on an older GNU/Linux > release) for ages with the same Windows SMB shares and never had this > problem. > > The GNU/Linux man pages of stat() and faccessat() don't mention EINTR > at all, and neither does POSIX > (https://pubs.opengroup.org/onlinepubs/9699919799/). > > So I guess the one million dollar question is this: > Are stat() and faccessat() permitted to return -1 with errno =3D=3D EINT= R, > or does that violate the POSIX (or some other) spec? > > I'll probably write a small test program next to check if I can > reproduce this problem outside of Emacs, maybe with a simple SIGALRM > and an endless loop of stat()/faccessat() calls. If that reproduces > the problem it would be nice to know whether using SA_RESTART in > sigaction() has any effect. > > Any ideas are very welcome... :) > > Tobias > > PS: I'm running Ubuntu focal (20.04.2 LTS, amd64), which currently > uses libc-bin 2.31-0ubuntu9.2, kernel linux-image-5.4.0-64-generic and > openconnect 8.05-1 to access the VPN. > --------------79751418E9043EBD02430DD5 Content-Type: text/x-csrc; charset=UTF-8; name="dont-interrupt-me.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="dont-interrupt-me.c" #include #include #include #include #include #include #include #include static const char path[] = "/smb/server/share/dir/subdir"; void handler (int signum) { static const char t[] = "handler called\n"; write (1, t, sizeof t); } int main () { struct stat st; struct sigaction action; struct itimerval timer; memset (&action, 0, sizeof action); action.sa_handler = handler; action.sa_flags = SA_RESTART; if (sigaction (SIGALRM, &action, NULL)) { perror ("sigaction() failed"); return 1; } timer.it_value.tv_sec = timer.it_interval.tv_sec = 0; timer.it_value.tv_usec = timer.it_interval.tv_usec = 1000000 / 10; if (setitimer (ITIMER_REAL, &timer, NULL)) { perror ("setitimer() failed"); return 1; } for (;;) { int r = stat (path, &st); if (r) { perror ("stat() failed"); return 1; } r = faccessat (AT_FDCWD, path, R_OK, 0); if (r) { perror ("faccessat() failed"); return 1; } } return 0; } --------------79751418E9043EBD02430DD5--