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#64821: 30.0.50; write-region errs when overwriting an already open file Date: Thu, 27 Jul 2023 22:02:45 +0300 Message-ID: <83edktkwiy.fsf@gnu.org> References: <2B783248-53AF-4486-8208-74A6B0A517EE@gmail.com> <83mszhl3j1.fsf@gnu.org> <4F213DB7-96C1-48F2-AE87-F22136C0848E@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37755"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64821@debbugs.gnu.org, yantar92@gmail.com To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 27 21:10:33 2023 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 1qP6Nb-0009ah-9b for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 27 Jul 2023 21:10:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP6GQ-0003pP-VQ; Thu, 27 Jul 2023 15:03:08 -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 1qP6GM-0003pD-OS for bug-gnu-emacs@gnu.org; Thu, 27 Jul 2023 15:03:02 -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 1qP6GM-0008Bb-Fs for bug-gnu-emacs@gnu.org; Thu, 27 Jul 2023 15:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qP6GM-00054J-2p for bug-gnu-emacs@gnu.org; Thu, 27 Jul 2023 15:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 Jul 2023 19:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64821 X-GNU-PR-Package: emacs Original-Received: via spool by 64821-submit@debbugs.gnu.org id=B64821.169048453219429 (code B ref 64821); Thu, 27 Jul 2023 19:03:02 +0000 Original-Received: (at 64821) by debbugs.gnu.org; 27 Jul 2023 19:02:12 +0000 Original-Received: from localhost ([127.0.0.1]:43136 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qP6FY-00053I-DU for submit@debbugs.gnu.org; Thu, 27 Jul 2023 15:02:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42838) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qP6FS-00052r-SB for 64821@debbugs.gnu.org; Thu, 27 Jul 2023 15:02:10 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qP6FL-0007wF-Nt; Thu, 27 Jul 2023 15:02:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=n87IAVs1xl4iJQnZnfOxd3Nf1vty2CCTowN4NbjUOm0=; b=b4v3Xox1PHE2Cia8yMhp ePaQi9urxYcZQQm1kiDQiAxvXShBwhWyvpeX8GUWq/s4wsAsWg1iFW5YxPgp1KkeO8GnN6/sm7F36 31oIEYMZ+oJ+W5JULKt5pNekDanN8YxoODKNzE+xdH6chePJ7H8TagLM7cN3YVawUvc1hg11vF8Br XUl6IClYa5SJvVn67cX8YtaHDBh5KYnH2Wp6yDzQNQhNwY3ncGxBILKW2++p88u0q3Od1+e5O+48c 5bx6SDEXdDcQKat/IvAKbP5oNrYj9PP3bvJlQi9i1+8GiS3kneEQFhfMQWTs752gCnTzZzSjhPKed nLb8ytJkoyZa6g==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qP6FH-0005Ju-90; Thu, 27 Jul 2023 15:01:57 -0400 In-Reply-To: <4F213DB7-96C1-48F2-AE87-F22136C0848E@gmail.com> (message from Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= on Thu, 27 Jul 2023 19:47:46 +0200) 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:266216 Archived-At: > From: Mattias EngdegÄrd > Date: Thu, 27 Jul 2023 19:47:46 +0200 > Cc: yantar92@gmail.com, > 64821@debbugs.gnu.org > > 27 juli 2023 kl. 18.31 skrev Eli Zaretskii : > > > Is that this line: > > > > (with-current-buffer (get-file-buffer (file-truename filename)) > > (set-visited-file-modtime)) > > Right, and it's probably because ERT creates temporary files in /var/something but on macOS, /var is a symlink to /private/var. In the lines above, filename (and file-truename) is the "/private/var/..." version. > Thus get-file-buffer won't return anything because buffer-file-name contains the non-true name, "/var/...". > > I have no idea if this is the right solution (probably not) but it makes filelock-tests all pass: Thanks, but I think we should make userlock.el robust in the face of such applications. How about the patch below instead? diff --git a/lisp/userlock.el b/lisp/userlock.el index 96de17d..92fea11 100644 --- a/lisp/userlock.el +++ b/lisp/userlock.el @@ -141,8 +141,10 @@ userlock--check-content-unchanged ;; modtime in that buffer, to cater to use case where the ;; file is about to be written to from some buffer that ;; doesn't visit any file, like a temporary buffer. - (with-current-buffer (get-file-buffer (file-truename filename)) - (set-visited-file-modtime)) + (let ((buf (get-file-buffer (file-truename filename)))) + (when buf + (with-current-buffer buf + (set-visited-file-modtime)))) 'unchanged))))) ;;;###autoload