Subject: bug#18982: 24.4.51; assertion violation in set_cache_region after revert-buffer

From: Eli Zaretskii <[email-masked]>
Date: Fri, 07 Nov 2014 15:17:26 +0200

> From: Nicolas Richard <[email-masked]>
> Date: Fri, 07 Nov 2014 12:22:29 +0100
> 
> 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
> [...]
> 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.

Thanks.  Is this reproducible?  If so, could you send a recipe?