[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Multiple uses of code-conversion-work buffer
From: |
Stefan Monnier |
Subject: |
Multiple uses of code-conversion-work buffer |
Date: |
Thu, 14 Jul 2005 01:46:50 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
I'm seeing strange error messages (typically about incorrect search bound in
utf-8-pre-write-conversion) when working under a tty and after tracking it
down, I ended up with the following backtrace:
#1 0x080fbd94 in set_conversion_work_buffer (multibyte=1) at coding.c:6041
#2 0x080fc0d8 in run_pre_write_conversin_on_c_str (str=0x85884f4,
size=0x85884f8, nchars=140285938, nbytes=140285938, coding=0x85b94e0)
at coding.c:6136
#3 0x0811424c in encode_terminal_code (src=0xb7a9fea8, src_len=46,
coding=0x85b94e0) at term.c:894
#4 0x081149af in write_glyphs (string=0xb7a9fc08, len=21) at term.c:970
#5 0x0805b42c in update_frame_line (f=0x85d5f58, vpos=54) at dispnew.c:5689
#6 0x0805a14d in update_frame_1 (f=0x85d5f58, force_p=1, inhibit_id_p=53)
at dispnew.c:5187
#7 0x08057eba in update_frame (f=0x85d5f58, force_p=1,
inhibit_hairy_id_p=140285938) at dispnew.c:3886
#8 0x08083f6e in echo_area_display (update_frame_p=1) at xdisp.c:8192
#9 0x0807fab0 in message2_nolog (m=0x8342305 "Garbage collecting...",
nbytes=21, multibyte=0) at xdisp.c:6979
#10 0x0808016c in message1_nolog (m=0x8342305 "Garbage collecting...")
at xdisp.c:7102
#11 0x081f350c in Fgarbage_collect () at alloc.c:4836
#12 0x0825de55 in Fbyte_code (bytestr=12345678, vector=138652485,
maxdepth=-1073749056) at bytecode.c:756
#13 0x0821aaf7 in funcall_lambda (fun=138652264, nargs=2,
arg_vector=0xbfffe524) at eval.c:3062
#14 0x08219f77 in Ffuncall (nargs=3, args=0xbfffe520) at eval.c:2923
#15 0x08219d30 in call2 (fn=141215530, arg1=49382712, arg2=49382876)
at eval.c:2683
#16 0x080fbf02 in run_pre_post_conversion_on_str (str=143233993,
coding=0xbfffe610, encodep=1) at coding.c:6090
...
So while performing some conversion, the pre/post-conversion hook (which is
utf-8-pre-write-conversion in this case) caused a GC to happen, which in
turn caused a message to be displayed (I have garbage-collection-messages
set to t) which required conversion as well, using the same buffer that was
still being converted.
I'm not sure what's the best way to fix it. Handa-san, any idea?
To catch this backtrace I used the patch below.
Stefan
--- orig/src/coding.c
+++ mod/src/coding.c
@@ -6024,6 +6024,7 @@
/* Name (or base name) of work buffer for code conversion. */
static Lisp_Object Vcode_conversion_workbuf_name;
+static Lisp_Object Vcode_conversion_workbuf_inuse;
/* Set the current buffer to the working buffer prepared for
code-conversion. MULTIBYTE specifies the multibyteness of the
@@ -6036,6 +6037,10 @@
Lisp_Object buffer;
struct buffer *buf;
+ if (!NILP (Vcode_conversion_workbuf_inuse))
+ abort();
+ /* error ("Reusing code conversion buffer"); */
+
buffer = Fget_buffer_create (Vcode_conversion_workbuf_name);
buf = XBUFFER (buffer);
delete_all_overlays (buf);
@@ -6075,6 +6080,7 @@
unibyte<->multibyte conversion. For that, we adjust the
multibyteness of the working buffer to that of STR. */
set_conversion_work_buffer (multibyte);
+ specbind (intern ("code_conversion_workbuf_inuse"), Qt);
insert_from_string (str, 0, 0,
SCHARS (str), SBYTES (str), 0);
@@ -6113,6 +6119,7 @@
int *size, nchars, nbytes;
struct coding_system *coding;
{
+ int count = SPECPDL_INDEX ();
struct gcpro gcpro1, gcpro2;
struct buffer *cur = current_buffer;
Lisp_Object old_deactivate_mark, old_last_coding_system_used;
@@ -6127,6 +6134,7 @@
unibyte<->multibyte conversion. For that, we adjust the
multibyteness of the working buffer to that of STR. */
set_conversion_work_buffer (coding->src_multibyte);
+ specbind (intern ("code_conversion_workbuf_inuse"), Qt);
insert_1_both (*str, nchars, nbytes, 0, 0, 0);
UNGCPRO;
inhibit_pre_post_conversion = 1;
@@ -6150,6 +6158,7 @@
coding->src_multibyte
= ! NILP (current_buffer->enable_multibyte_characters);
set_buffer_internal (cur);
+ unbind_to (count, Qnil);
}
@@ -7659,6 +7668,9 @@
staticpro (&Vcode_conversion_workbuf_name);
Vcode_conversion_workbuf_name = build_string (" *code-conversion-work*");
+ DEFVAR_LISP ("code_conversion_workbuf_inuse",
&Vcode_conversion_workbuf_inuse, Doc: /* */);
+ Vcode_conversion_workbuf_inuse = Qnil;
+
Qtarget_idx = intern ("target-idx");
staticpro (&Qtarget_idx);
- Multiple uses of code-conversion-work buffer,
Stefan Monnier <=