From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file Date: Fri, 12 Feb 2021 09:43:25 +0200 Message-ID: <83pn15g28y.fsf@gnu.org> References: <87h7mllgin.fsf@nexoid.at> <83a6scj745.fsf@gnu.org> <39d0e035-27b6-e2bd-daa2-747dda2c1a35@cs.ucla.edu> <835z2ziu52.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40248"; mail-complaints-to="usenet@ciao.gmane.io" Cc: gmatta@gmail.com, 46397@debbugs.gnu.org, eggert@cs.ucla.edu, craven@gmx.net To: Matt Armstrong Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 12 08:44:19 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 1lAT7i-000ALY-RJ for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Feb 2021 08:44:18 +0100 Original-Received: from localhost ([::1]:45188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAT7h-0007L6-Gc for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Feb 2021 02:44:17 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAT7S-0007Kl-EC for bug-gnu-emacs@gnu.org; Fri, 12 Feb 2021 02:44:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48310) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lAT7S-0003Iq-6g for bug-gnu-emacs@gnu.org; Fri, 12 Feb 2021 02:44:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lAT7S-00053e-4s for bug-gnu-emacs@gnu.org; Fri, 12 Feb 2021 02:44:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Feb 2021 07:44: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.161311581019397 (code B ref 46397); Fri, 12 Feb 2021 07:44:02 +0000 Original-Received: (at 46397) by debbugs.gnu.org; 12 Feb 2021 07:43:30 +0000 Original-Received: from localhost ([127.0.0.1]:59856 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lAT6w-00052n-EA for submit@debbugs.gnu.org; Fri, 12 Feb 2021 02:43:30 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:45036) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lAT6u-00052Z-WF for 46397@debbugs.gnu.org; Fri, 12 Feb 2021 02:43:29 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:32857) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAT6n-00030w-M7; Fri, 12 Feb 2021 02:43:21 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3440 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lAT6n-0006Vf-5A; Fri, 12 Feb 2021 02:43:21 -0500 In-Reply-To: (message from Matt Armstrong on Wed, 10 Feb 2021 14:39:36 -0800) 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:199844 Archived-At: > From: Matt Armstrong > Cc: Paul Eggert , gmatta@gmail.com, > 46397@debbugs.gnu.org, craven@gmx.net > Date: Wed, 10 Feb 2021 14:39:36 -0800 > > > We should not ignore these errors, we should ask the user what to do > > about them. The user can tell us the error can be ignored, but we > > should not decide that without asking. > > I think Paul's commit is a good one. I'll try to explain why. > > The commit does not silently ignore ENOTDIR. Instead, it is explicitly > handles that particular error code it in a way that honors the lock file > API contract. I said "silently" because the user is left unaware of what Emacs did in this case. We don't even show a warning or any other informative message. > In this case, Paul's commit changes the current_lock_owner() function > such that it returns zero upon ENOTDIR. The caller must interpret the > zero return as meaning "at the time current_lock_owner() was called, > nobody owned the lock file...or the lock file was obsolete." > > ENOTDIR has a specific meaning that we can rely on. Both ENOENT and > ENOTDIR imply that the file was definitely not on disk at the time of > the call. Because of this, current_lock_owner() can safely conclude that > nobody owned the lock. "Definitely"? "safely"? How do you arrive at that conclusion? The Posix spec of 'unlink' says: [ENOTDIR] A component of the path prefix names an existing file that is neither a directory nor a symbolic link to a directory, or the path argument contains at least one non- character and ends with one or more trailing characters and the last pathname component names an existing file that is neither a directory nor a symbolic link to a directory. It doesn't even say which component of the file name is not a directory, nor does it distinguish between the two different use cases that could cause ENOTDIR. How can current_lock_owner decide, on these shaky grounds alone, that nobody owned the lock, let alone do that 'safely"? My point is that the values of errno provide too little information for a safe decision here, one that couldn't possibly be wrong. It could be the scenario that triggered this bug report, but it could be something entirely different. We just don't know enough, and any assumptions in this situation can definitely err. Which is why I still think that we need to bring the user into the loop. Users will know what could or did happen, and even if they don't, they are in charge of resolving the situation. These problems are rare enough to not make prompting the user for the appropriate action an annoyance, so there's no good reason not to do so. Doing so will, as a nice bonus, also solve similar problems for any other value of errno, once and for all.