Subject: 25.0.50; segfault in backward-prefix-chars

From: martin rudalics <[email-masked]>
Date: Sun, 14 Dec 2014 10:17:24 +0100

With emacs -Q inserting at the beginning of *scratch* the text

`((1
    2
    3)

then trying to insert a final closing ")" gets me

Program received signal SIGSEGV, Segmentation fault.
0x011d30f8 in Fbackward_prefix_chars () at syntax.c:3049
3049		DEC_BOTH (pos, pos_byte);
(gdb) bt
#0  0x011d30f8 in Fbackward_prefix_chars () at syntax.c:3049
#1  0x01195753 in Ffuncall (nargs=1, args=0x82e5a8) at eval.c:2720
#2  0x011d822a in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=1, args=0x82e900) at bytecode.c:920
#3  0x01195f62 in funcall_lambda (fun=..., nargs=1, arg_vector=0x82e8fc) at eval.c:2890
#4  0x0119598e in Ffuncall (nargs=2, args=0x82e8f8) at eval.c:2772
#5  0x011d822a in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=0, args=0x82ec58) at bytecode.c:920
#6  0x01195f62 in funcall_lambda (fun=..., nargs=0, arg_vector=0x82ec58) at eval.c:2890
#7  0x0119598e in Ffuncall (nargs=1, args=0x82ec54) at eval.c:2772
#8  0x011d822a in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=0, args=0x82f02c) at bytecode.c:920
#9  0x01195f62 in funcall_lambda (fun=..., nargs=0, arg_vector=0x82f02c) at eval.c:2890
#10 0x0119598e in Ffuncall (nargs=1, args=0x82f028) at eval.c:2772
#11 0x01194d75 in funcall_nil (nargs=1, args=0x82f028) at eval.c:2354
#12 0x01195186 in run_hook_with_args (nargs=1, args=0x82f028, funcall=0x1194d5d <funcall_nil>) at eval.c:2539
#13 0x01194db5 in Frun_hooks (nargs=1, args=0x15501c0) at eval.c:2381
#14 0x0114f64b in internal_self_insert (c=41, n=1) at cmds.c:510
#15 0x0114ebd9 in Fself_insert_command (n=...) at cmds.c:310
#16 0x01195770 in Ffuncall (nargs=2, args=0x82f2d4) at eval.c:2723
#17 0x0118d170 in Ffuncall_interactively (nargs=2, args=0x82f2d4) at callint.c:270
#18 0x01195664 in Ffuncall (nargs=3, args=0x82f2d0) at eval.c:2703
#19 0x0118eed3 in Fcall_interactively (function=..., record_flag=..., keys=...) at callint.c:876
#20 0x011957c5 in Ffuncall (nargs=4, args=0x82f53c) at eval.c:2730
#21 0x011d822a in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=1, args=0x82f8a0) at bytecode.c:920
#22 0x01195f62 in funcall_lambda (fun=..., nargs=1, arg_vector=0x82f89c) at eval.c:2890
#23 0x0119598e in Ffuncall (nargs=2, args=0x82f898) at eval.c:2772
#24 0x011952a4 in call1 (fn=..., arg1=...) at eval.c:2576
#25 0x01103e95 in command_loop_1 () at keyboard.c:1576
#26 0x011926bb in internal_condition_case (bfun=0x11037b5 <command_loop_1>, handlers=..., hfun=0x1103017 <cmd_error>) at eval.c:1344
#27 0x0110346b in command_loop_2 (ignore=...) at keyboard.c:1197
#28 0x01191c5a in internal_catch (tag=..., func=0x1103447 <command_loop_2>, arg=...) at eval.c:1105
#29 0x01103425 in command_loop () at keyboard.c:1176
#30 0x01102bb3 in recursive_edit_1 () at keyboard.c:786
#31 0x01102d70 in Frecursive_edit () at keyboard.c:857
#32 0x01100d82 in main (argc=2, argv=0xa32880) at emacs.c:1623

Lisp Backtrace:
"backward-prefix-chars" (0x82e5ac)
"forward-sexp" (0x82e8fc)
"blink-matching-open" (0x82ec58)
"blink-paren-post-self-insert-function" (0x82f02c)
"self-insert-command" (0x82f2d8)
"funcall-interactively" (0x82f2d4)
"call-interactively" (0x82f540)
"command-execute" (0x82f89c)
(gdb)

I have no idea what happened because of

(gdb) p pos
$1 = 0
(gdb) p beg
$2 = 1
(gdb) p pos_byte
$3 = 0

so

       if (pos + 1 > beg)
	DEC_BOTH (pos, pos_byte);

should not have been taken, in principle at least ...

This is with a not entirely up-to-date build of my GNU Emacs 25.0.50.1
(i686-pc-mingw32).

martin