From: Joel Rosdahl <joel@rosdahl.net>
To: 31981@debbugs.gnu.org
Subject: bug#31981: Fix 'flymake-proc-legacy-flymake' temporary file deletion bug
Date: Tue, 27 Aug 2019 22:35:04 +0200 [thread overview]
Message-ID: <CAK8D=phJy_oVHT7LaLz4EdoznrrcdsvhFwUoeV8HTibqcwWFgg@mail.gmail.com> (raw)
In-Reply-To: <ly7emljw7e.fsf@ensc-virt.intern.sigma-chemnitz.de>
[-- Attachment #1: Type: text/plain, Size: 1178 bytes --]
I can reproduce this bug on latest master.
The problem is that if a check command takes a long time, the
following can happen:
1. The user modifies the buffer, making flymake-proc start a process A
which reads from a temporary file T containing the buffer content.
2. Before process A has finished, the user modifies the buffer again,
making flymake-proc start a new process B reading from the same
temporary file T.
3. A is marked as obsolete.
4. When A's sentinel detects that A has died, it runs A's cleanup
function which deletes T.
5. B may fail since T is gone.
Attached is a patch which solves the issue, at least for me: simply
don't run the cleanup function for an obsolete process. This should
work well for checks that use flymake-proc-simple-cleanup or one of
the other cleanup functions defined in flymake-proc.el.
I'm not sure if the fix is appropriate for the general case with a
user-supplied custom cleanup function, though. But I see no other
quick fix for the issue since the name of the temporary file is kept
in a single buffer-local variable and there is no way for the cleanup
function to know that it's being called for an obsolete process.
-- Joel
[-- Attachment #2: 0001-Fix-flymake-proc-temporary-file-deletion-bug.patch --]
[-- Type: text/x-patch, Size: 1577 bytes --]
From fef0fe5ed6cec78e87f29444af8d400bcbd01e72 Mon Sep 17 00:00:00 2001
From: Joel Rosdahl <joel@rosdahl.net>
Date: Tue, 27 Aug 2019 22:00:45 +0200
Subject: [PATCH] Fix flymake-proc temporary file deletion bug
* list/progmodes/flymake-proc.el (flymake-proc--process-sentinel):
Don't run cleanup if this is an obsolete process -- deleting the
temporary file will make the the active process fail since it uses the
same file. (Bug#31981)
---
lisp/progmodes/flymake-proc.el | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el
index 2d5a47a07978..2095de6117e5 100644
--- a/lisp/progmodes/flymake-proc.el
+++ b/lisp/progmodes/flymake-proc.el
@@ -649,7 +649,12 @@ flymake-proc--process-sentinel
(flymake-log 3 "Output buffer %s kept alive for debugging"
output-buffer))
(t
- (when (buffer-live-p source-buffer)
+ (when (and (buffer-live-p source-buffer)
+ ;; Don't run cleanup if this is an obsolete
+ ;; process -- deleting the temporary file
+ ;; will make the the active process fail
+ ;; since it uses the same file (bug#31981):
+ (not (process-get proc 'flymake-proc--obsolete)))
(with-current-buffer source-buffer
(let ((cleanup-f (flymake-proc--get-cleanup-function
(buffer-file-name))))
--
2.20.1
next prev parent reply other threads:[~2019-08-27 20:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-26 17:26 bug#31981: 26.1; flymake: removes temporary file before finishing check Enrico Scholz
2019-08-27 20:35 ` Joel Rosdahl [this message]
2019-08-27 23:37 ` bug#31981: Fix 'flymake-proc-legacy-flymake' temporary file deletion bug Noam Postavsky
2019-08-28 19:18 ` Joel Rosdahl
2019-08-29 16:04 ` Noam Postavsky
2019-08-29 17:30 ` Joel Rosdahl
2019-09-07 21:05 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAK8D=phJy_oVHT7LaLz4EdoznrrcdsvhFwUoeV8HTibqcwWFgg@mail.gmail.com' \
--to=joel@rosdahl.net \
--cc=31981@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).