From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#72641: 31.0.50; "Unlocking file: Invalid argument" when deleting lock file on network file system Date: Thu, 15 Aug 2024 20:20:36 -0700 Organization: UCLA Computer Science Department Message-ID: References: <867cfujge6.fsf@gnu.org> <86fruhiwt0.fsf@gnu.org> <868r09ivqn.fsf@gnu.org> <867cftiprt.fsf@gnu.org> <86msoph6wt.fsf@gnu.org> <2+lcnmedng9le3pwfn0gc79m@mina86.com> <86a5hd7o4t.fsf@gnu.org> <+b8wcnteufggsda3gtf7ioja@mina86.com> <0aecnuy9e9nb2pjfpz4dpvqk@mina86.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------5uVRUmz4QCqo3wpxnGXZtVii" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22651"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: 72641@debbugs.gnu.org To: Michal Nazarewicz , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Aug 16 05:21:51 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1senXC-0005nU-L6 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 16 Aug 2024 05:21:51 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1senWp-0008Qd-N1; Thu, 15 Aug 2024 23:21:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1senWo-0008QR-3w for bug-gnu-emacs@gnu.org; Thu, 15 Aug 2024 23:21:26 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1senWn-0004jC-RV for bug-gnu-emacs@gnu.org; Thu, 15 Aug 2024 23:21:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=In-Reply-To:From:References:MIME-Version:Date:To:Subject; bh=mzb8pKrPkCaZ74mFFjCPF/2YuH2vqhXoQzuVREoGurM=; b=mDLNSHlPrWCXG0sjAkXrOSW2kjMHhBZj7i2u5hjYzhV6QwOgtDxyx2oXjhRARZoi2nceLg5mZUIEOG/u0MIc4Mt1UVuNcncKiLFb5kZOzpgBLfvnCvTWqPvPC+uAvkHAowjJC1Sa0y1TIDAP6xTe+dulNlbuE8+j5EmjO2IQLNS9dQDpYncbwKwftZlvvptgTuiShoio/kWPAetVnDB/8JTmPGVh93cqF5TwdjgRNAW1/UbVnbtVmFiFvpFNL5tWarHZgboK8fG1s6rgod89FXINqP9KUbx0+MzRtK84OibfAguJvIqFlhssCNyCGP5fxf01qRt27LLiGc2PSXTMEQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1senXN-0003Ic-Q9 for bug-gnu-emacs@gnu.org; Thu, 15 Aug 2024 23:22:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 16 Aug 2024 03:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72641 X-GNU-PR-Package: emacs Original-Received: via spool by 72641-submit@debbugs.gnu.org id=B72641.172377848112613 (code B ref 72641); Fri, 16 Aug 2024 03:22:01 +0000 Original-Received: (at 72641) by debbugs.gnu.org; 16 Aug 2024 03:21:21 +0000 Original-Received: from localhost ([127.0.0.1]:50081 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1senWi-0003HM-Vz for submit@debbugs.gnu.org; Thu, 15 Aug 2024 23:21:21 -0400 Original-Received: from mail.cs.ucla.edu ([131.179.128.66]:47710) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1senWh-0003HA-DM for 72641@debbugs.gnu.org; Thu, 15 Aug 2024 23:21:19 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id DED0A3C0140A4; Thu, 15 Aug 2024 20:20:36 -0700 (PDT) Original-Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP id X77LKnILGeDy; Thu, 15 Aug 2024 20:20:36 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 4F8B83C00E405; Thu, 15 Aug 2024 20:20:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu 4F8B83C00E405 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1723778436; bh=mzb8pKrPkCaZ74mFFjCPF/2YuH2vqhXoQzuVREoGurM=; h=Message-ID:Date:MIME-Version:To:From; b=DuxcLGCckCxUDTF8bdpmSprrM9+wm3JdEzH+6QW05LJSaQIr+c6YurXzBD37ZknkP KDrU+5MPI90LPJNIApiq0svc9E0CQtu1RASTQoSjEsDfaHlOT8bpopMGyfy99YOXDw C9uLVTEVYlLqoLIsKwuuxTwDbAfYdR3Nz4BlgaJJbIko/F7vXQnCSutew1JsIjBHyO WCs/A+7WO0k2y6nEQmXEryDpsuJhnmKb2OCHmLbJn65pny8UXFKsqovsL8myKfQHKQ mRI5CnwvQbX4aTNLmcWT/ONMBTHsCb+m3mfOSeXJkg0m0oC4wNhaW74LmH+fQUajbz 2Ww9B4WcsFimw== X-Virus-Scanned: amavis at mail.cs.ucla.edu Original-Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id YKM_D0IBpUvN; Thu, 15 Aug 2024 20:20:36 -0700 (PDT) Original-Received: from [192.168.254.12] (unknown [47.150.137.250]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id 3141E3C0140A4; Thu, 15 Aug 2024 20:20:36 -0700 (PDT) Content-Language: en-US In-Reply-To: <0aecnuy9e9nb2pjfpz4dpvqk@mina86.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:290191 Archived-At: This is a multi-part message in MIME format. --------------5uVRUmz4QCqo3wpxnGXZtVii Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable On 2024-08-15 17:59, Michal Nazarewicz wrote: > However, if I save the file (be it by save-buffer or by killing the > buffer and picking save option), the lock file remains.... > - unlock_file is called > - it calls current_lock_owner > - which return ENOENT for some reason > - the lock file is left alone Obviously current_lock_owner should not return ENOENT if there is an=20 existing lock file - that would defeat the purpose of having a lock=20 file. We need to get to the bottom of why current_lock_owner returns ENOE= NT. From inspection, current_lock_owner returns ENOENT only if Emacs=20 notices that the "lock" file is actually an empty regular file (or looks=20 stale), and calls 'unlink' on it, and 'unlink' fails with errno =3D=3D=20 ENOENT. Is that what's actually happening? You can use a debugger or=20 'strace' to confirm. Come to think of it, if 'unlink' fails with errno =3D=3D ENOENT, that mea= ns=20 there's no lock file so current_lock_owner should return 0. This is true=20 because of NFS and similar network file systems where unlink can fail=20 even though it actually removed the file. I installed the attached patch=20 to fix this; a similar problem exists elsewhere, so this patch fixes all=20 the instances of it in Emacs master. With this patch, current_lock_owner should never return ENOENT and we=20 can move on to the next problem you observe, if there is one. > In desperation I=E2=80=99ve tried attached patch (it adds `if (!lfinfol= en) > return I_OWN_IT`; big diff is because than `if (lfinfolen)` check can b= e > removed and code dedented) and it worked. Yes, that doesn't sound right; on non-buggy file systems the invalid=20 lock file would cause races to occur, if I'm reading the code correctly. Let's see what happens with current master before proceeding in any=20 direction like that. --------------5uVRUmz4QCqo3wpxnGXZtVii Content-Type: text/x-patch; charset=UTF-8; name="0001-Port-better-to-NFS-unlink.patch" Content-Disposition: attachment; filename="0001-Port-better-to-NFS-unlink.patch" Content-Transfer-Encoding: base64 RnJvbSA5YWFkNzY2NDgxM2Q3N2Y0ZGFiMjY0OWQ1NmFkYmYxMjIzOWI3NTA1IE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8ZWdnZXJ0QGNzLnVjbGEuZWR1 PgpEYXRlOiBUaHUsIDE1IEF1ZyAyMDI0IDIwOjEwOjUzIC0wNzAwClN1YmplY3Q6IFtQQVRD SF0gUG9ydCBiZXR0ZXIgdG8gTkZTIHVubGluawpNSU1FLVZlcnNpb246IDEuMApDb250ZW50 LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9VVRGLTgKQ29udGVudC1UcmFuc2Zlci1FbmNv ZGluZzogOGJpdAoKSSBmb3VuZCB0aGlzIHByb2JsZW0gd2hpbGUgbG9va2luZyBpbnRvIEJ1 ZyM3MjY0MS4KKiBsaWItc3JjL2V0YWdzLmMgKGRvX21vdmVfZmlsZSk6CiogbGliLXNyYy91 cGRhdGUtZ2Ft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