[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fwd: Crash when buffer is edited while save-buffer asks for coding s
From: |
Kenichi Handa |
Subject: |
Re: Fwd: Crash when buffer is edited while save-buffer asks for coding system |
Date: |
Thu, 10 Jan 2008 10:31:19 +0900 |
User-agent: |
SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/23.0.60 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
In article <address@hidden>, Glenn Morris <address@hidden> writes:
> Does anyone have any ideas about this? It causes a reproducible crash
> (see very nice recipe below) with the current EMACS_22_BASE on
> Gnu/Linux, so it would be good to fix.
> It happens because when Fwrite_region calls
> Vselect_safe_coding_system_function, it opens a window for the user to
> modify the buffer mid-save. The abort in buf_charpos_to_bytepos in
> marker.c due to changed buffer size is what causes the actual crash.
> One easy solution is to for Fwrite_region to make the buffer read-only
> while Vselect_safe_coding_system_function is called. That will protect
> against accidental editing of the buffer at least, but of course a
> determined user could still make the buffer writable again.
> Ideally, I think one would want errors during write-region to abort
> the write, not Emacs.
I installed the following fix last year, but it was only to
the trunk. Could someone who already has the working
directory of EMACS_22_BASE install it?
2007-12-27 Kenichi Handa <address@hidden>
* international/mule-cmds.el (select-safe-coding-system):
When a buffer is modified, cancel the writing.
Index: mule-cmds.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/mule-cmds.el,v
retrieving revision 1.316
retrieving revision 1.317
diff -u -r1.316 -r1.317
--- mule-cmds.el 6 Dec 2007 00:46:17 -0000 1.316
+++ mule-cmds.el 27 Dec 2007 10:27:21 -0000 1.317
@@ -966,6 +966,7 @@
(let ((codings (find-coding-systems-region from to))
(coding-system nil)
+ (tick (if (not (stringp from)) (buffer-modified-tick)))
safe rejected unsafe)
(if (eq (car codings) 'undecided)
;; Any coding system is ok.
@@ -1030,6 +1031,8 @@
%s specified by file contents. Really save (else edit coding cookies \
and try again)? " coding-system auto-cs))
(error "Save aborted"))))
+ (when (and tick (/= tick (buffer-modified-tick)))
+ (error "Cancelled because the buffer was modified"))
coding-system)))
(setq select-safe-coding-system-function 'select-safe-coding-system)
Diffs between 1.316 and 1.317 end here.