bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#778: 23.0.60; Assuming errstring unibyte is incorrect and leads to E


From: Dmitry Dzhus
Subject: bug#778: 23.0.60; Assuming errstring unibyte is incorrect and leads to Emacs crashes
Date: Tue, 26 Aug 2008 02:27:33 +0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Looks like the code of `report_file_error' function at fileio.c assumes
errstring is unibyte after `code_convert_string_norecord' call.

    str = strerror (errorno);
    errstring = code_convert_string_norecord (make_unibyte_string (str,
                                                                 strlen (str)),
                                            Vlocale_coding_system, 0);
    …
    /* System error messages are capitalized.  Downcase the initial
           unless it is followed by a slash.  */
        if (SREF (errstring, 1) != '/')
          SSET (errstring, 0, DOWNCASE (SREF (errstring, 0)));

That's not always true. 

The result of `code_convert_string_norecord' results in a multibyte
string object when `CODING_FOR_UNIBYTE (Vlocale_coding_system)' is not
true, that is indicated by code in `decode_coding_object' function from
coding.c:

    if (EQ (dst_object, Qt)
      || (! NILP (CODING_ATTR_POST_READ (attrs))
          && NILP (dst_object)))
    {
      coding->dst_multibyte = !CODING_FOR_UNIBYTE (coding);
      …

Here's a part of GDB debugging session which indicates that `errstring'
may really be not so unibyte as it seems at the first glance:

     (gdb) break report_file_error
     Breakpoint 3 at 0x81b5b1a: file fileio.c, line 246.
     (gdb) run
     Starting program: /home/sphinx/projects/emacs/src/emacs 
     [Thread debugging using libthread_db enabled]
     [New Thread 0xb71996c0 (LWP 29806)]
     [Switching to Thread 0xb71996c0 (LWP 29806)]

     Breakpoint 3, report_file_error (string=0x8292f16 "Removing old name", 
data=151779485) at fileio.c:246
     246          int errorno = errno;
     (gdb) next
     250          str = strerror (errorno);
     (gdb) 
     251          errstring = code_convert_string_norecord (make_unibyte_string 
(str,
     (gdb) next
     252                                                                        
 strlen (str)),
     (gdb) next
     257              {
     (gdb) print ((struct Lisp_String *)errstring)->size_byte
     $1 = 0

Testing `errstring' with `STRING_MULTIBYTE' macro also succeeds (I
failed to prove that with GDB as all `lisp.h' macros seem to be mangled
even when Emacs is built with `-gdwarf-2 -g3' options — have I missed
something or it's really so?).

When using a system locale like ru_RU.UTF-8, which has a non-ASCII
initial character («Нет такого файла…») in error message (returned by
`strerror(3)' call), the assumption about `errstring' unibyteness leads
to corrupting `errstring' while downcasing its initial character because
the character doesn't necessarily occupy only one byte. Thus SSET&SREF
should not be used.

Now to the bug introduced by current approach. It's reproducible under
locales meeting the conditions stated in the previous paragraph, for
example ru_RU.UTF-8.

When trying to complete a file name from non-existent directory (for
example, completing a name of file to visit with
C-x C-f ~/non-existent-dir/foo/file TAB), Emacs crashes, because after
an error signal is raised in `report_file_error', Emacs attempts to
print a message containing a downcased `errstring'. When calling a
`multibyte_chars_in_text' function (see character.c), an invalid
sequence is encountered and `abort(3)' is called:

    int len = MULTIBYTE_LENGTH (ptr, endp);

    if (len == 0)
      abort ();

I've attached a full backtrace to prove my words.

(gdb) bt full
#0  0xb7fc4424 in __kernel_vsyscall ()
#1  0xb73c1b36 in kill () from /lib/libc.so.6
#2  0x0817d638 in abort () at emacs.c:417
#3  0x080eb10c in multibyte_chars_in_text (ptr=0xbffe0310 "ð\235еÑ\202 
Ñ\202акого Ñ\204айла или каÑ\202алогаg directory", nbytes=54) at character.c:622
#4  0x080eaf1a in chars_in_text (ptr=0xbffe0310 "ð\235еÑ\202 Ñ\202акого 
Ñ\204айла или каÑ\202алогаg directory", nbytes=54) at character.c:601
#5  0x081ac2f0 in insert_1 (string=0x6aa4 <Address 0x6aa4 out of bounds>, 
nbytes=54, inherit=1, prepare=0, before_markers=0) at insdel.c:832
#6  0x0807cf29 in message_dolog (m=0xbffe0310 "ð\235еÑ\202 Ñ\202акого Ñ\204айла 
или каÑ\202алогаg directory", nbytes=54, nlflag=0, multibyte=1) at xdisp.c:7797
#7  0x08226d0d in strout (ptr=0xbffe0310 "ð\235еÑ\202 Ñ\202акого Ñ\204айла или 
каÑ\202алогаg directory", size=29, size_byte=54, printcharfun=138541305, 
multibyte=1) at print.c:391
#8  0x082272f5 in print_string (string=148959003, printcharfun=138541305) at 
print.c:492
#9  0x0822b8ff in print_object (obj=148959003, printcharfun=138541305, 
escapeflag=0) at print.c:1609
#10 0x0822ac50 in print (obj=148959003, printcharfun=138541305, escapeflag=0) 
at print.c:1304
#11 0x08229a3c in Fprinc (object=148959003, printcharfun=138541305) at 
print.c:846
#12 0x0822a76a in print_error_message (data=152594509, stream=138541305, 
context=0xbffe07fe "", caller=143775649) at print.c:1103
#13 0x08180e43 in cmd_error_internal (data=152594509, context=0xbffe07fe "") at 
keyboard.c:1283
#14 0x08180c93 in cmd_error (data=152594509) at keyboard.c:1222
#15 0x08209bcb in internal_condition_case (bfun=0x81811ce <command_loop_1>, 
handlers=138584497, hfun=0x8180ba8 <cmd_error>) at eval.c:1501
#16 0x08180f20 in command_loop_2 () at keyboard.c:1338
#17 0x082096e0 in internal_catch (tag=138679777, func=0x8180efb 
<command_loop_2>, arg=138541257) at eval.c:1247
#18 0x08180e87 in command_loop () at keyboard.c:1303
#19 0x081807b4 in recursive_edit_1 () at keyboard.c:942
#20 0x081b2ee8 in read_minibuf (map=138534365, initial=140556051, 
prompt=137135435, backup_n=0, expflag=0, histvar=138601377, histpos=0, 
defalt=151520131, allow_props=0, inherit_input_method=0) at minibuf.c:735
#21 0x081b4cfe in Fcompleting_read (prompt=137135435, collection=138732609, 
predicate=138541257, require_match=138541257, initial_input=140556051, 
hist=138601377, def=151520131, inherit_input_method=138541257) at minibuf.c:1814
#22 0x0820c2db in Ffuncall (nargs=8, args=0xbffe0cc0) at eval.c:3073
#23 0x082507c6 in Fbyte_code (bytestr=137220851, vector=137220868, maxdepth=72) 
at bytecode.c:678
#24 0x0820c876 in funcall_lambda (fun=137220764, nargs=4, 
arg_vector=0xbffe0fe4) at eval.c:3229
#25 0x0820c323 in Ffuncall (nargs=5, args=0xbffe0fe0) at eval.c:3088
#26 0x082507c6 in Fbyte_code (bytestr=137135051, vector=137135068, maxdepth=40) 
at bytecode.c:678
#27 0x0820c876 in funcall_lambda (fun=137135012, nargs=2, 
arg_vector=0xbffe12f4) at eval.c:3229
#28 0x0820c323 in Ffuncall (nargs=3, args=0xbffe12f0) at eval.c:3088
#29 0x082507c6 in Fbyte_code (bytestr=137135387, vector=137135412, maxdepth=24) 
at bytecode.c:678
#30 0x0820b24b in Feval (form=137135373) at eval.c:2379
#31 0x08205fea in Fcall_interactively (function=143687033, 
record_flag=138541257, keys=138579692) at callint.c:361
#32 0x0820c0ee in Ffuncall (nargs=4, args=0xbffe18a0) at eval.c:3048
#33 0x0820bcab in call3 (fn=138705537, arg1=143687033, arg2=138541257, 
arg3=138541257) at eval.c:2872
#34 0x08191282 in Fcommand_execute (cmd=143687033, record_flag=138541257, 
keys=138541257, special=138541257) at keyboard.c:10338
#35 0x08182998 in command_loop_1 () at keyboard.c:1879
#36 0x08209c24 in internal_condition_case (bfun=0x81811ce <command_loop_1>, 
handlers=138584497, hfun=0x8180ba8 <cmd_error>) at eval.c:1511
#37 0x08180f20 in command_loop_2 () at keyboard.c:1338
#38 0x082096e0 in internal_catch (tag=138580473, func=0x8180efb 
<command_loop_2>, arg=138541257) at eval.c:1247
#39 0x08180ed9 in command_loop () at keyboard.c:1317
#40 0x081807b4 in recursive_edit_1 () at keyboard.c:942
#41 0x08180923 in Frecursive_edit () at keyboard.c:1004
#42 0x0817f201 in main (argc=1, argv=0xbffe2134) at emacs.c:1689

bt full
#0  0xb8024424 in __kernel_vsyscall ()
No symbol table info available.
#1  0xb7420b36 in kill () from /lib/libc.so.6
No symbol table info available.
#2  0x0817d658 in abort () at emacs.c:417
No locals.
#3  0x080eb10c in multibyte_chars_in_text (ptr=0xbfd41850 "ð\235еÑ\202 
Ñ\202акого Ñ\204айла или каÑ\202алогаg directory", nbytes=54) at character.c:622
        len = 0
        endp = (const unsigned char *) 0xbfd41886 "g directory"
        chars = 0
#4  0x080eaf1a in chars_in_text (ptr=0xbfd41850 "ð\235еÑ\202 Ñ\202акого 
Ñ\204айла или каÑ\202алогаg directory", nbytes=54) at character.c:601
No locals.
#5  0x081ac310 in insert_1 (string=0x75ba <Address 0x75ba out of bounds>, 
nbytes=54, inherit=1, prepare=0, before_markers=0) at insdel.c:832
No locals.
#6  0x0807cf29 in message_dolog (m=0xbfd41850 "ð\235еÑ\202 Ñ\202акого Ñ\204айла 
или каÑ\202алогаg directory", nbytes=54, nlflag=0, multibyte=1) at xdisp.c:7797
        oldpoint = 138755994
        oldbuf = (struct buffer *) 0x88c7eb8
        oldbegv = 138756018
        oldzv = 138756042
        old_windows_or_buffers_changed = 221
        zv_at_end = 1
        gcpro1 = {next = 0x1, var = 0xbfd41798, nvars = 135972507}
        point_at_end = 1
        old_deactivate_mark = 138541305
        tem = 138726609
#7  0x08226d2d in strout (ptr=0xbfd41850 "ð\235еÑ\202 Ñ\202акого Ñ\204айла или 
каÑ\202алогаg directory", size=29, size_byte=54, printcharfun=138541305, 
multibyte=1) at print.c:391
        i = 0
        multibyte_p = 1
#8  0x08227315 in print_string (string=142340163, printcharfun=138541305) at 
print.c:492
        nbytes = 54
        buffer = 0xbfd41850 "ð\235еÑ\202 Ñ\202акого Ñ\204айла или каÑ\202алогаg 
directory"
        sa_count = 33
        sa_must_free = 0
        chars = 29
#9  0x0822b91f in print_object (obj=142340163, printcharfun=138541305, 
escapeflag=0) at print.c:1609
        buf = 
"*\022D\bú\210c\bùøA\b\000\000\000\000ú\210c\b*\022D\bh\033Կ±8\037\b\031\017D\bùøA\b"
#10 0x0822ac70 in print (obj=142340163, printcharfun=138541305, escapeflag=0) 
at print.c:1304
No locals.
#11 0x08229a5c in Fprinc (object=142340163, printcharfun=138541305) at 
print.c:846
        old = (struct buffer *) 0x8567e00
        old_point = -1
        start_point = -1
        old_point_byte = -1
        start_point_byte = -1
        specpdl_count = 33
        free_print_buffer = 0
        multibyte = 1
        original = 138541305
#12 0x0822a78a in print_error_message (data=152776557, stream=138541305, 
context=0xbfd41d3e "", caller=143775649) at print.c:1103
        obj = 142340163
        errname = 138601401
        errmsg = 142340147
        file_error = 138533813
        tail = 152575253
        gcpro1 = {next = 0xbfd41cd8, var = 0x80f9424, nvars = 141433952}
        i = 0
#13 0x08180e63 in cmd_error_internal (data=152776557, context=0xbfd41d3e "") at 
keyboard.c:1283
        sf = (struct frame *) 0x86e1c60
#14 0x08180cb3 in cmd_error (data=152776557) at keyboard.c:1222
        old_level = 138541257
        old_length = 138541257
        macroerror = "\000\000-\000\000\000\000~V\b\000\000\000\000 
\034Կ\003\000\000\000\001\000\000\000ÉøA\b)BD\b,D=\bsÞÞ\001/\000\000\000\000\000\000"
#15 0x08209beb in internal_condition_case (bfun=0x81811ee <command_loop_1>, 
handlers=138584497, hfun=0x8180bc8 <cmd_error>) at eval.c:1501
        val = 138541257
        c = {tag = 138541257, val = 152776557, next = 0xbfd41ea0, gcpro = 0x0, 
jmp = {{__jmpbuf = {138726609, 136006338, 148823731, -1076617624, 590807405, 
-902057470}, __mask_was_saved = 0, __saved_mask = {__val = {138541257, 
138541257, 143775769, 32, 0, 0, 0, 
          2, 3218349688, 136364867, 137330364, 0, 3218349832, 1, 138755634, 
4508881, 3218349640, 0, 138755634, 138700945, 138541257, 0, 0, 139496752, 
139886080, 12, 2, 0, 138541257, 3218349916, 3218349828, 3218349832}}}}, 
backlist = 0xbfd421ac, 
  handlerlist = 0xbfd42fd8, lisp_eval_depth = 5, pdlcount = 33, 
poll_suppress_count = 1, interrupt_input_blocked = 0, byte_stack = 0xbfd422b8}
        h = {handler = 138584497, var = 138541257, chosen_clause = 138541305, 
tag = 0xbfd41d9c, next = 0xbfd42fd8}
#16 0x08180f40 in command_loop_2 () at keyboard.c:1338
        val = -1076619184
#17 0x08209700 in internal_catch (tag=138679777, func=0x8180f1b 
<command_loop_2>, arg=138541257) at eval.c:1247
        c = {tag = 138679777, val = 138541257, next = 0xbfd42fec, gcpro = 0x0, 
jmp = {{__jmpbuf = {138726609, 136006338, 148823731, -1076617368, 590422381, 
-903749118}, __mask_was_saved = 0, __saved_mask = {__val = {138541257, 
138541257, 138541257, 3218349832, 
          136362167, 2, 3218349828, 0, 139161693, 138541257, 1, 14, 14, 
138726609, 143712649, 3218349976, 136363962, 1, 3218350020, 3218349928, 
136265187, 138772177, 138783058, 138541257, 139886080, 0, 138702418, 138702418, 
138541257, 138541257, 138783058, 
          138783058}}}}, backlist = 0xbfd421ac, handlerlist = 0xbfd42fd8, 
lisp_eval_depth = 5, pdlcount = 33, poll_suppress_count = 1, 
interrupt_input_blocked = 0, byte_stack = 0xbfd422b8}
#18 0x08180ea7 in command_loop () at keyboard.c:1303
        val = 138726609
#19 0x081807d4 in recursive_edit_1 () at keyboard.c:942
        count = 32
        val = 138541257
#20 0x081b2f08 in read_minibuf (map=138534365, initial=148823731, 
prompt=137135435, backup_n=0, expflag=0, histvar=138601377, histpos=0, 
defalt=142056499, allow_props=0, inherit_input_method=0) at minibuf.c:735
        val = 138541257
        count = 25
        mini_frame = 141433956
        ambient_dir = 142056499
        minibuffer = 139886084
        input_method = 138541257
        gcpro1 = {next = 0x9176b85, var = 0x841f8c9, nvars = 13}
        gcpro2 = {next = 0x844e05a, var = 0x841f8c9, nvars = 152508440}
        gcpro3 = {next = 0xbfd42078, var = 0x81f3de3, nvars = 138732681}
        gcpro4 = {next = 0x1, var = 0xb746f617, nvars = -1}
        gcpro5 = {next = 0x8411410, var = 0x90bdfcc, nvars = 13}
        enable_multibyte = 138541257
        pos = 0
        histstring = 0
        empty_minibuf = 138673540
        dummy = 138541257
        frame = 141433956
#21 0x081b4d1e in Fcompleting_read (prompt=137135435, collection=138732609, 
predicate=138541257, require_match=138541257, initial_input=148823731, 
hist=138601377, def=142056499, inherit_input_method=138541257) at minibuf.c:1814
        val = 2020501864
        histvar = 138601377
        histpos = 0
        position = 138541257
        init = 148823731
        pos = 0
        count = 22
        gcpro1 = {next = 0x1, var = 0x841f8e1, nvars = 138541281}
#22 0x0820c2fb in Ffuncall (nargs=8, args=0xbfd42200) at eval.c:3073
        fun = 136978452
        original_fun = 138734849
        funcar = -1076616728
        numargs = 7
        lisp_numargs = 138584401
        val = 152529485
        backtrace = {next = 0xbfd424cc, function = 0xbfd42200, args = 
0xbfd42204, nargs = 7, evalargs = 0 '\0', debug_on_exit = 0 '\0'}
        internal_args = (Lisp_Object *) 0xbfd42150
        i = 8
#23 0x0825080e in Fbyte_code (bytestr=137220875, vector=137220892, maxdepth=72) 
at bytecode.c:678
        count = 14
        op = 7
        vectorp = (Lisp_Object *) 0x82dd320
        bytestr_length = 396
        stack = {pc = 0x83abd9e "+\202ë", top = 0xbfd4221c, bottom = 
0xbfd42200, byte_string = 137220875, byte_string_start = 0x83abce8 
"\b\204\006", constants = 137220892, next = 0xbfd425c8}
        top = (Lisp_Object *) 0xbfd42200
        result = 152529797
#24 0x0820c896 in funcall_lambda (fun=137220788, nargs=4, 
arg_vector=0xbfd42524) at eval.c:3229
        val = 152529797
        syms_left = 138541257
        next = 143705897
        count = 8
        i = 4
        optional = 1
        rest = 0
#25 0x0820c343 in Ffuncall (nargs=5, args=0xbfd42520) at eval.c:3088
        fun = 137220788
        original_fun = 143686985
        funcar = -1076615928
        numargs = 4
        lisp_numargs = 138699065
        val = 152529797
        backtrace = {next = 0xbfd427dc, function = 0xbfd42520, args = 
0xbfd42524, nargs = 4, evalargs = 0 '\0', debug_on_exit = 0 '\0'}
        internal_args = (Lisp_Object *) 0x841f8e1
        i = -1076615960
#26 0x0825080e in Fbyte_code (bytestr=137135051, vector=137135068, maxdepth=40) 
at bytecode.c:678
        count = 5
        op = 4
        vectorp = (Lisp_Object *) 0x82c83e0
        bytestr_length = 29
        stack = {pc = 0x83b7719 "+ÍD\207", top = 0xbfd42530, bottom = 
0xbfd42520, byte_string = 137135051, byte_string_start = 0x83b7700 "\b\205\a", 
constants = 137135068, next = 0xbfd428c8}
        top = (Lisp_Object *) 0xbfd42520
        result = 1
#27 0x0820c896 in funcall_lambda (fun=137135012, nargs=2, 
arg_vector=0xbfd42834) at eval.c:3229
        val = 0
        syms_left = 138541257
        next = 143667713
        count = 3
        i = 2
        optional = 0
        rest = 0
#28 0x0820c343 in Ffuncall (nargs=3, args=0xbfd42830) at eval.c:3088
        fun = 137135012
        original_fun = 143709049
        funcar = 138541257
        numargs = 2
        lisp_numargs = 148973513
        val = 4
        backtrace = {next = 0xbfd42af4, function = 0xbfd42830, args = 
0xbfd42834, nargs = 2, evalargs = 0 '\0', debug_on_exit = 0 '\0'}
        internal_args = (Lisp_Object *) 0xd
        i = -1076615144
#29 0x0825080e in Fbyte_code (bytestr=137135387, vector=137135412, maxdepth=24) 
at bytecode.c:678
        count = 3
        op = 2
        vectorp = (Lisp_Object *) 0x82c8538
        bytestr_length = 9
        stack = {pc = 0x83b76ba "\207", top = 0xbfd42838, bottom = 0xbfd42830, 
byte_string = 137135387, byte_string_start = 0x83b76b2 "ÁÂ\b\205\a", constants 
= 137135412, next = 0x0}
        top = (Lisp_Object *) 0xbfd42830
        result = 185244162
#30 0x0820b26b in Feval (form=137135373) at eval.c:2379
        numargs = 24
        args_left = 138541257
        i = 3
        maxargs = 3
        argvals = {137135387, 137135412, 24, 136534413, 138542308, 138541257, 
16, 16}
        fun = 138238748
        val = 138541257
        original_fun = 138704257
        original_args = 137135381
        funcar = 0
        backtrace = {next = 0xbfd42d7c, function = 0xbfd42b0c, args = 
0xbfd42ab0, nargs = 3, evalargs = 1 '\001', debug_on_exit = 0 '\0'}
        gcpro1 = {next = 0xbfd42b38, var = 0x81f2fec, nvars = 138679801}
        gcpro2 = {next = 0x81ed069, var = 0x84415f9, nvars = 152529813}
        gcpro3 = {next = 0x9176b8d, var = 0xbfd42ab0, nvars = 3}
#31 0x0820600a in Fcall_interactively (function=143687033, 
record_flag=138541257, keys=138579692) at callint.c:361
        input = 137135373
        args = (Lisp_Object *) 0x0
        visargs = (Lisp_Object *) 0x0
        specs = 137135373
        filter_specs = 137135373
        teml = 0
        up_event = 138541257
        enable = 138541257
        speccount = 3
        next_event = 0
        prefix_arg = 138541257
        string = (unsigned char *) 0x0
        tem = (unsigned char *) 0x0
        varies = (int *) 0x0
        i = 2
        j = 143687033
        count = 0
        foo = 0
        prompt1 = "ô\177U·ð5Կ \000\000\000@\221U·\034«F·@\221U· 
\000\000\000ô\177U·ð5Կð5Կø*Կ\000\000\000\000YvB\b\235JJ\b\000 ", '\0' <repeats 
41 times>
        tem1 = 0x0
        arg_from_tty = 0
        gcpro1 = {next = 0x841f8c9, var = 0x1fa, nvars = 268}
        gcpro2 = {next = 0x841f8e1, var = 0x0, nvars = 0}
        gcpro3 = {next = 0x841f8c9, var = 0x841f8c9, nvars = 148842209}
        gcpro4 = {next = 0x8907d79, var = 0x141f8e1, nvars = -1076614440}
        gcpro5 = {next = 0x0, var = 0x0, nvars = 48}
        key_count = 2
        record_then_fail = 0
        save_this_command = 143687033
        save_last_command = 138541257
        save_this_original_command = 143687033
        save_real_this_command = 143687033
#32 0x0820c10e in Ffuncall (nargs=4, args=0xbfd42de0) at eval.c:3048
        fun = 138232108
        original_fun = 138705537
        funcar = 0
        numargs = 3
        lisp_numargs = 0
        val = 0
        backtrace = {next = 0x0, function = 0xbfd42de0, args = 0xbfd42de4, 
nargs = 3, evalargs = 0 '\0', debug_on_exit = 0 '\0'}
        internal_args = (Lisp_Object *) 0xbfd42de4
        i = 0
#33 0x0820bccb in call3 (fn=138705537, arg1=143687033, arg2=138541257, 
arg3=138541257) at eval.c:2872
        ret_ungc_val = 137135260
        gcpro1 = {next = 0xbfd42dd8, var = 0x82149bb, nvars = 4}
#34 0x081912a2 in Fcommand_execute (cmd=143687033, record_flag=138541257, 
keys=138541257, special=138541257) at keyboard.c:10338
        final = 137135260
        tem = 138541257
        prefixarg = 138541257
#35 0x081829b8 in command_loop_1 () at keyboard.c:1879
        scount = 2
        cmd = 143687033
        lose = 134479872
        nonundocount = 0
        keybuf = {192, 48, -1207678960, -1218825576, 110932256, 134547696, 0, 
-1207689604, -1472036457, 88216588, 56, -1220580084, -1220585164, 0, 1011, 0, 
0, 1, 1010, -1223781912, -1218825576, 134547696, -1220543604, 134526076, 1, 
-1207681084, -1207678960, 0, 
  -1076613236, -1076613520}
        i = 2
        prev_modiff = 49
        prev_buffer = (struct buffer *) 0x9171818
        already_adjusted = 0
#36 0x08209c44 in internal_condition_case (bfun=0x81811ee <command_loop_1>, 
handlers=138584497, hfun=0x8180bc8 <cmd_error>) at eval.c:1511
        val = 138857837
        c = {tag = 138541257, val = 138541257, next = 0xbfd430f0, gcpro = 0x0, 
jmp = {{__jmpbuf = {-1219133452, -1076611600, -1076611600, -1076612936, 
592683373, -902057470}, __mask_was_saved = 0, __saved_mask = {__val = 
{3075838272, 3087277692, 276967387, 
          8655230, 56, 3074387212, 3074386228, 138868295, 1011, 3076141720, 0, 
1, 2034, 3218354608, 138464064, 3218354580, 3218354440, 135914852, 2, 
3218354452, 3218354300, 3074403372, 3076141720, 3218354300, 110932256, 
3087286212, 3087287896, 134526076, 1, 
          3087223750, 3087288336, 3071185384}}}}, backlist = 0x0, handlerlist = 
0x0, lisp_eval_depth = 0, pdlcount = 2, poll_suppress_count = 1, 
interrupt_input_blocked = 0, byte_stack = 0x0}
        h = {handler = 138584497, var = 138541257, chosen_clause = 148970315, 
tag = 0xbfd42fec, next = 0x0}
#37 0x08180f40 in command_loop_2 () at keyboard.c:1338
        val = -1076619184
#38 0x08209700 in internal_catch (tag=138580473, func=0x8180f1b 
<command_loop_2>, arg=138541257) at eval.c:1247
        c = {tag = 138580473, val = 138541257, next = 0x0, gcpro = 0x0, jmp = 
{{__jmpbuf = {-1219133452, -1076611600, -1076611600, -1076612680, 594395501, 
-903749118}, __mask_was_saved = 0, __saved_mask = {__val = {0, 0, 0, 0, 0, 2, 
3074853535, 0, 0, 0, 0, 0, 0, 
          1, 3074853535, 0, 0, 0, 3075838328, 3218354616, 136265187, 138772177, 
138783058, 138541257, 138567112, 3075714146, 3075838328, 138673216, 138541257, 
138541257, 138783058, 138783058}}}}, backlist = 0x0, handlerlist = 0x0, 
lisp_eval_depth = 0, 
  pdlcount = 2, poll_suppress_count = 1, interrupt_input_blocked = 0, 
byte_stack = 0x0}
#39 0x08180ef9 in command_loop () at keyboard.c:1317
No locals.
#40 0x081807d4 in recursive_edit_1 () at keyboard.c:942
        count = 1
        val = -1076611600
#41 0x08180943 in Frecursive_edit () at keyboard.c:1004
        count = 0
        buffer = 138541257
#42 0x0817f221 in main (argc=1, argv=0xbfd43674) at emacs.c:1689
        dummy = -1223782044
        stack_bottom_variable = -65 '¿'
        do_initial_setlocale = 1
        skip_args = 0
        rlim = {rlim_cur = 8388608, rlim_max = 18446744073709551615}
        no_loadup = 0
        junk = 0x0
(gdb) xbacktrace 
"completing-read" (0xbfbb2034)
"read-file-name" (0xbfbb2354)
"find-file-read-args" (0xbfbb2664)
"byte-code" (0xbfbb28e0)
"call-interactively" (0xbfbb2c14)
Looks like the issue may be resolved replacing a SSET&SREF call at
`report_file_error' with something multibyte-aware. I've attached a
one-line patch which does the job. It makes an assertion that a downcase
and uppercase character both occupy the same amount of bytes.

*** fileio.c.~1.629.~   2008-08-06 01:41:14.000000000 +0400
--- fileio.c    2008-08-26 02:09:11.000000000 +0400
***************
*** 262,268 ****
        /* System error messages are capitalized.  Downcase the initial
           unless it is followed by a slash.  */
        if (SREF (errstring, 1) != '/')
!         SSET (errstring, 0, DOWNCASE (SREF (errstring, 0)));
  
        xsignal (Qfile_error,
                 Fcons (build_string (string), Fcons (errstring, data)));
--- 262,268 ----
        /* System error messages are capitalized.  Downcase the initial
           unless it is followed by a slash.  */
        if (SREF (errstring, 1) != '/')
!         CHAR_STRING (DOWNCASE (STRING_CHAR (SDATA(errstring), 0)), 
SDATA(errstring));
  
        xsignal (Qfile_error,
                 Fcons (build_string (string), Fcons (errstring, data)));
Using `Fdowncase' function instead also fixes the problem, but at a cost
of slight overhead (the whole string gets processed, not just the first
character (this cannot impact performance seriously though, as I believe
those `errstring' variables are not processed often)) my patch does not
introduce.

I've tested the patch with several locales (both problematic and
traditional ones) and couldn't spot any regression introduced with this
patch.

The rest of this message contains additional information about my Emacs
installation.

In GNU Emacs 23.0.60.1 (i686-pc-linux-gnu, GTK+ Version 2.12.11)
 of 2008-08-26 on blizzard
Windowing system distributor `The X.Org Foundation', version 11.0.10402000

configured using `configure '--prefix=/usr' '--host=i686-pc-linux-gnu'
'--mandir=/usr/share/man' '--infodir=/usr/share/info'
'--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib'
'--program-suffix=-emacs-23' '--infodir=/usr/share/info/emacs-23'
'--with-sound' '--with-x' '--with-toolkit-scroll-bars' '--with-gif'
'--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xpm'
'--with-freetype' '--with-xft' '--without-libotf' '--without-m17n-flt'
'--with-x-toolkit=gtk' '--without-hesiod' '--without-kerberos'
'--without-kerberos5' '--with-gpm' '--with-dbus'
'--build=i686-pc-linux-gnu' 'build_alias=i686-pc-linux-gnu'
'host_alias=i686-pc-linux-gnu' 'CFLAGS=-O2 -march=native -pipe'
'LDFLAGS=-Wl,-O1''

Important settings:
  value of $LC_ALL: 
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: C
  value of $LC_TIME: nil
  value of $LANG: ru_RU.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t
-- 
Happy Hacking.

http://sphinx.net.ru

reply via email to

[Prev in Thread] Current Thread [Next in Thread]