Subject: 24.4.51; assertion violation in set_cache_region after revert-buffer
From: Nicolas Richard <[email-masked]>
To: [email-masked]
Date: Fri, 07 Nov 2014 12:22:29 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

Context : I was looking at an org file which had obviously not been
properly decoded (it's an utf8 file, I was seeing raw bytes and the
"buffer coding system" in the mode line was blank). So I decided to M-x
revert-buffer to see if I could do something with it. That crashed.

Here's the backtrace:

Breakpoint 1, terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:351
351	  signal (sig, SIG_DFL);
#0  terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:351
#1  0x0827d8c5 in die (msg=0x83e4420 "c->buffer_beg <= start && end <= c->buffer_end", 
    file=0x83e42b0 "region-cache.c", line=364) at alloc.c:6833
#2  0x08325b0d in set_cache_region (c=0xae3f540, start=8828, end=8835, value=1) at region-cache.c:364
#3  0x08326205 in know_region_cache (buf=0xb01f410, c=0xae3f540, start=8828, end=8835) at region-cache.c:671
#4  0x0825a4bb in find_newline (start=8828, start_byte=8828, end=8836, end_byte=8836, count=1, shortage=0xbffea18c, 
    bytepos=0xbffea190, allow_quit=true) at search.c:812
#5  0x0824d8a0 in Fforward_line (n=1) at cmds.c:138
#6  0x0828f9a9 in Fline_beginning_position (n=2) at editfns.c:772
#7  0x082aaa45 in Ffuncall (nargs=2, args=0xbffea3b0) at eval.c:2812
#8  0x08307b43 in exec_byte_code (bytestr=-9223372036715234836, vector=-6917529027501540868, maxdepth=6, 
    args_template=4611686018569232232, nargs=0, args=0x0) at bytecode.c:916
#9  0x082abf76 in funcall_lambda (fun=-6917529027501540928, nargs=3, arg_vector=0xbffeabb8) at eval.c:3045
#10 0x082aaff8 in Ffuncall (nargs=4, args=0xbffeabb0) at eval.c:2861
#11 0x082a9809 in funcall_nil (nargs=4, args=0xbffeabb0) at eval.c:2363
#12 0x082a9e3e in run_hook_with_args (nargs=4, args=0xbffeabb0, funcall=0x82a97f1 <funcall_nil>) at eval.c:2548
#13 0x082a988d in Frun_hook_with_args (nargs=4, args=0xbffeabb0) at eval.c:2409
#14 0x082aa8e9 in Ffuncall (nargs=5, args=0xbffeaba8) at eval.c:2793
#15 0x08307b43 in exec_byte_code (bytestr=-9223372036715217532, vector=-6917529027501523564, maxdepth=12, 
    args_template=771, nargs=3, args=0xbffeb2a8) at bytecode.c:916
#16 0x082ab926 in funcall_lambda (fun=-6917529027501523624, nargs=3, arg_vector=0xbffeb290) at eval.c:2979
#17 0x082aaff8 in Ffuncall (nargs=4, args=0xbffeb288) at eval.c:2861
#18 0x082a9809 in funcall_nil (nargs=4, args=0xbffeb288) at eval.c:2363
#19 0x082a9e3e in run_hook_with_args (nargs=4, args=0xbffeb288, funcall=0x82a97f1 <funcall_nil>) at eval.c:2548
#20 0x082a988d in Frun_hook_with_args (nargs=4, args=0xbffeb288) at eval.c:2409
#21 0x08230303 in signal_after_change (charpos=18, lendel=0, lenins=8809) at insdel.c:2084
#22 0x082446ee in Finsert_file_contents (filename=-9223372036495053568, visit=4611686018569232272, 
    beg=4611686018569232232, end=4611686018569232232, replace=4611686018569232272) at fileio.c:4320
#23 0x082aac3f in Ffuncall (nargs=6, args=0xbfffb9c8) at eval.c:2828
#24 0x08307b43 in exec_byte_code (bytestr=-9223372036715877820, vector=-6917529027502183852, maxdepth=8, 
    args_template=514, nargs=2, args=0xbfffc000) at bytecode.c:916
#25 0x082ab926 in funcall_lambda (fun=-6917529027502183912, nargs=2, arg_vector=0xbfffbff0) at eval.c:2979
#26 0x082aaff8 in Ffuncall (nargs=3, args=0xbfffbfe8) at eval.c:2861
#27 0x08307b43 in exec_byte_code (bytestr=-9223372036715878344, vector=-6917529027502184376, maxdepth=12, 
    args_template=514, nargs=2, args=0xbfffc608) at bytecode.c:916
#28 0x082ab926 in funcall_lambda (fun=-6917529027502184436, nargs=2, arg_vector=0xbfffc5f8) at eval.c:2979
#29 0x082aaff8 in Ffuncall (nargs=3, args=0xbfffc5f0) at eval.c:2861
#30 0x08307b43 in exec_byte_code (bytestr=-9223372036715878540, vector=-6917529027502184572, maxdepth=6, 
    args_template=768, nargs=1, args=0xbfffcc60) at bytecode.c:916
#31 0x082ab926 in funcall_lambda (fun=-6917529027502184640, nargs=1, arg_vector=0xbfffcc58) at eval.c:2979
#32 0x082aaff8 in Ffuncall (nargs=2, args=0xbfffcc50) at eval.c:2861
#33 0x082a9247 in Fapply (nargs=2, args=0xbfffcc50) at eval.c:2298
#34 0x082a9fe5 in apply1 (fn=4611686018569233440, arg=-4611686017974323136) at eval.c:2585
#35 0x0829d683 in Fcall_interactively (function=4611686018569233440, record_flag=4611686018573540520, 
    keys=-6917529027254129160) at callint.c:378
#36 0x082aaafc in Ffuncall (nargs=4, args=0xbfffd178) at eval.c:2819
#37 0x08307b43 in exec_byte_code (bytestr=-9223372036715516220, vector=-6917529027501822252, maxdepth=13, 
    args_template=1025, nargs=2, args=0xbfffd7a0) at bytecode.c:916
#38 0x082ab926 in funcall_lambda (fun=-6917529027501822312, nargs=2, arg_vector=0xbfffd790) at eval.c:2979
#39 0x082aaff8 in Ffuncall (nargs=3, args=0xbfffd788) at eval.c:2861
#40 0x08307b43 in exec_byte_code (bytestr=-9223372036715516748, vector=-6917529027501822780, maxdepth=15, 
    args_template=513, nargs=2, args=0xbfffdd98) at bytecode.c:916
#41 0x082ab926 in funcall_lambda (fun=-6917529027501822848, nargs=2, arg_vector=0xbfffdd88) at eval.c:2979
#42 0x082aaff8 in Ffuncall (nargs=3, args=0xbfffdd80) at eval.c:2861
#43 0x082a97b5 in Fapply (nargs=2, args=0xbfffde50) at eval.c:2351
#44 0x082a9fe5 in apply1 (fn=4611686018569508680, arg=-4611686017918257024) at eval.c:2585
#45 0x0829d683 in Fcall_interactively (function=4611686018569508680, record_flag=4611686018569232232, 
    keys=-6917529027254129160) at callint.c:378
#46 0x082aaafc in Ffuncall (nargs=4, args=0xbfffe378) at eval.c:2819
#47 0x08307b43 in exec_byte_code (bytestr=-9223372036715516220, vector=-6917529027501822252, maxdepth=13, 
    args_template=1025, nargs=1, args=0xbfffe978) at bytecode.c:916
#48 0x082ab926 in funcall_lambda (fun=-6917529027501822312, nargs=1, arg_vector=0xbfffe970) at eval.c:2979
#49 0x082aaff8 in Ffuncall (nargs=2, args=0xbfffe968) at eval.c:2861
#50 0x082aa076 in call1 (fn=4611686018569274840, arg1=4611686018569508680) at eval.c:2611
#51 0x081de6c3 in command_loop_1 () at keyboard.c:1559
#52 0x082a56be in internal_condition_case (bfun=0x81ddc39 <command_loop_1>, handlers=4611686018569278920, 
    hfun=0x81dcf49 <cmd_error>) at eval.c:1348
#53 0x081dd6ed in command_loop_2 (ignore=4611686018569232232) at keyboard.c:1177
#54 0x082a471b in internal_catch (tag=4611686018569275680, func=0x81dd6b2 <command_loop_2>, arg=4611686018569232232)
    at eval.c:1112
#55 0x081dd676 in command_loop () at keyboard.c:1156
#56 0x081dc968 in recursive_edit_1 () at keyboard.c:777
#57 0x081dcc1e in Frecursive_edit () at keyboard.c:848
#58 0x081da5b4 in main (argc=2, argv=0xbfffee04) at emacs.c:1646

Lisp Backtrace:
"line-beginning-position" (0xbffea3b8)
"font-lock-extend-jit-lock-region-after-change" (0xbffeabb8)
"run-hook-with-args" (0xbffeabb0)
"jit-lock-after-change" (0xbffeb290)
"insert-file-contents" (0xbfffb9d0)
"revert-buffer-insert-file-contents--default-function" (0xbfffbff0)
"revert-buffer--default" (0xbfffc5f8)
"revert-buffer" (0xbfffcc58)
"call-interactively" (0xbfffd180)
"command-execute" (0xbfffd790)
"execute-extended-command" (0xbfffdd88)
"call-interactively" (0xbfffe380)
"command-execute" (0xbfffe970)

And some more info :

(gdb) frame 2
#2  0x08325b0d in set_cache_region (c=0xae3f540, start=8828, end=8835, value=1) at region-cache.c:364
364       eassert (c->buffer_beg <= start && end <= c->buffer_end);
(gdb) p c->buffer_beg
$1 = 1
(gdb) p c->buffer_end
$2 = 27

FWIW the file which I was reverting certainly is bigger than 27 bytes :
(point-max) currently evals to 8626 in that file (and I didn't modify it
since the crash).

gdb session still alive if needed.

The crash happened with GNU Emacs 24.4.51.2 (although I'm reporting it
with 24.3.90 because $nogoodreason).

Important settings:
  value of $LANG: fr_FR.UTF-8
  locale-coding-system: utf-8-unix

-- 
Nicolas Richard