Subject: Re: bug#61887: 30.0.50; Segfault on revert-buffer-with-coding-system

From: Eli Zaretskii <[email-masked]>
Date: Wed, 01 Mar 2023 14:47:07 +0200

> Date: Tue, 28 Feb 2023 23:48:18 +0200
> From: Petteri Hintsanen <[email-masked]>
> 
> After editing a binary file in nhexl-mode, calling 
> revert-buffer-with-coding-system crashed Emacs.  This happened initially 
> on Emacs 28.2, but the current master branch crashes as well.
> 
> Preparation:
> 
> - Get nhexl-mode-1.5 from ELPA.
> 
> - Create a test file "junk.dat" with:
> 
>      dd if=/dev/random of=junk.dat bs=1k count=5k
> 
>    or use any existing large binary file (5 MBs or more).
> 
> Recipe:
> 
> ./gdb --args emacs -Q
> 
> In *scratch* buffer, type
> 
>    (add-to-list 'load-path "~/.emacs.d/elpa/nhexl-mode-1.5")
>    (require 'nhexl-mode)
> 
> M-x eval-buffer
> 
> M-x find-file-literally junk.dat
> 
> M-x nhexl-mode RET
> 
> M-x nhexl-mode RET
> 
> C-x RET r utf-8 RET yes RET

Thank you for your report.

Stefan, can you please look into this?  It sounds like nhexl-mode
leaves an interval tree in the buffer which causes problems when
reverting non-literally.  (Maybe reverting non-literally after
visiting literally, or vice versa, should dispose of all the
intervals?)