From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matt Armstrong Newsgroups: gmane.emacs.bugs Subject: bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file Date: Tue, 09 Feb 2021 16:23:09 -0800 Message-ID: References: <87h7mllgin.fsf@nexoid.at> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6522"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) Cc: 46397@debbugs.gnu.org, Paul Eggert To: "Peter" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 10 02:48:18 2021 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 1l9ec5-0001aA-Ke for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Feb 2021 02:48:17 +0100 Original-Received: from localhost ([::1]:53814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9ec4-0007hC-Ka for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 09 Feb 2021 20:48:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9ebs-0007gq-Fc for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 20:48:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9ebq-0003dv-V4 for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 20:48:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l9ebq-0003i7-UG for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 20:48:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Matt Armstrong Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Feb 2021 01:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46397 X-GNU-PR-Package: emacs Original-Received: via spool by 46397-submit@debbugs.gnu.org id=B46397.161292164514190 (code B ref 46397); Wed, 10 Feb 2021 01:48:02 +0000 Original-Received: (at 46397) by debbugs.gnu.org; 10 Feb 2021 01:47:25 +0000 Original-Received: from localhost ([127.0.0.1]:55187 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9ebF-0003gi-8v for submit@debbugs.gnu.org; Tue, 09 Feb 2021 20:47:25 -0500 Original-Received: from mail-pj1-f47.google.com ([209.85.216.47]:53762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9dHo-0001an-R9 for 46397@debbugs.gnu.org; Tue, 09 Feb 2021 19:23:18 -0500 Original-Received: by mail-pj1-f47.google.com with SMTP id nm1so126645pjb.3 for <46397@debbugs.gnu.org>; Tue, 09 Feb 2021 16:23:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=js0vBbkSTghLM2Q32AV1OkMLCy4TK+L2M2oaRHh4gNY=; b=Z/YR2C4n0AyKxkkvTzHjn1fYyvxTuOyX7Sxvd8tYqVzAdJiygwdETb3tRxIP6MQZ5X UZDgcwNjN+X9YCygnXiatHhBJOf4dUvs6huh1I+y6xRFNVw7Y2BlpsmdDAoX38wYCive m2jAQhNVmDfBIMlNMrF/cjrN5uadXE9G4tO/f3AcVt72ucwXWXSxFcHxHBZIpWf/WG0w BDbucGHzOACkRYyyNL7xcusybJV+I1PpdAOXuPMJylXhO0UjJF41hHSSHELSq4wXRKpm +iv8L1wwLt8vufdMqslFpIzOhBT6D/6mFYmsW3SIFjTVLFtx7fM8OmvaPAhROnqh8v+K Q/gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=js0vBbkSTghLM2Q32AV1OkMLCy4TK+L2M2oaRHh4gNY=; b=LQ2NZtmZsycGU4iS0em4R2G/9xwu3j+hweaeI/S//5W/9bBq7pPKcMr0Jy/MhmpJ+1 Q2vrsY38ZBMMPBeqdlOtPTeREQU9kDhpuNQAbK7B5oPPGbQMiUtZvAV37E5pXyrsoJEE NpOUoTOEA8H6ORbjsp3/qBQYmprIvF93ey96XcE3H0FvRwu7IE6Tj+ArkNeMbrGq5hdA MYKP+4OYYRQkVYg9cMQIt+DnKnvuVG1OHIKyfBdcrseB/UuVX6cMtRw0VliBOJN27LBZ XGsj5gYQp5WDHV+QiaCQMAipivHqQxHKviVvwSKhVmsocDkJTqJ4U2Mih1NXB4swpBuF SQVA== X-Gm-Message-State: AOAM531xBKVUUENxA0pnpqyQb+7RVIs3SN3uISdtL4cExW2YgkGko8dD MzCESKUFv7JUUokAt49876Y= X-Google-Smtp-Source: ABdhPJzp0oHNTw7/qFzgdws5ZC3i7jPC1yiUCo0PIpFklixc3JeTDrmojj8xtenxMqGoL8zIrT8NLg== X-Received: by 2002:a17:902:8a95:b029:e3:484:a4a with SMTP id p21-20020a1709028a95b02900e304840a4amr61994plo.13.1612916590656; Tue, 09 Feb 2021 16:23:10 -0800 (PST) Original-Received: from matts-mbp-2016.lan (24-113-169-116.wavecable.com. [24.113.169.116]) by smtp.gmail.com with ESMTPSA id v9sm179313pju.33.2021.02.09.16.23.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 16:23:10 -0800 (PST) X-Google-Original-From: Matt Armstrong In-Reply-To: (Matt Armstrong's message of "Tue, 09 Feb 2021 15:47:44 -0800") X-Mailman-Approved-At: Tue, 09 Feb 2021 20:47:23 -0500 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" Xref: news.gmane.io gmane.emacs.bugs:199750 Archived-At: --=-=-= Content-Type: text/plain Matt Armstrong writes: > "Peter" writes: > >> The following steps reproduce this: >> - Make sure /tmp/tmp does not exist >> - Open a buffer /tmp/tmp/foo.txt >> - Make some changes to the buffer. >> - Do *not* save the buffer or create the directory /tmp/tmp/ >> - Create /tmp/tmp as a *file* (not a directory) >> - Try to kill the buffer. >> >> You will see the following error message: >> >> Unlocking file: Not a directory, /tmp/tmp/foo.txt >> >> I just want to kill the buffer, I don't want to save it. [...] > The backtrace is unsurprising: > > Debugger entered--Lisp error: (file-error "Unlocking file" "Not a directory" "/private/tmp/tmp/test.txt") > kill-buffer("test.txt") > funcall-interactively(kill-buffer "test.txt") > call-interactively(kill-buffer nil nil) > command-execute(kill-buffer) I found that this behavior was introduced by Paul Egger's commit 9dc306b1db0, discussed in Bug#37389. I've cc'd Paul. Paul's commit changed unlock_file() (from src/filelock.cc) to report errors from unlink(), excempting only ENOENT. This bug demonstrates a way to induce an ENOTDIR error. I've attached a patch that ignores ENOTDIR as well, which is the most conservative fix I can think of. It also seems in-line with Paul's original intent, since he was saying that both ENOENT and ENOTDIR are usually "tame." --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Ignore-ENOTDIR-errors-from-unlink.patch Content-Description: Ignore ENOTDIR >From fc0b7f2595bd8680952f062d2dd5261f94394e1c Mon Sep 17 00:00:00 2001 From: Matt Armstrong Date: Tue, 9 Feb 2021 16:14:28 -0800 Subject: [PATCH] Ignore ENOTDIR errors from unlink(). * src/filelock.c (unlock_file): Ignore ENOTDIR errors from unlink(). --- src/filelock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/filelock.c b/src/filelock.c index 35baa0c666..af5683f365 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -731,7 +731,8 @@ unlock_file (Lisp_Object fn) MAKE_LOCK_NAME (lfname, fn); int err = current_lock_owner (0, lfname); - if (err == -2 && unlink (lfname) != 0 && errno != ENOENT) + if (err == -2 && unlink (lfname) != 0 + && (errno != ENOENT && errno != ENOTDIR)) err = errno; if (0 < err) report_file_errno ("Unlocking file", filename, err); -- 2.30.0 --=-=-=--