Subject: bug#67900: 30.0.50; Emacs Crahes When Executing Command `consult-buffer'

From: Eli Zaretskii <[email-masked]>
Date: Fri, 22 Dec 2023 09:41:27 +0200

> From: Chang Xiaoduan <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>,  [email-masked]
> Date: Fri, 22 Dec 2023 11:44:57 +0800
> 
> Andrea Corallo <[email-masked]> writes:
> 
> > But before starting with a blind bisect I think we should try if any of
> > the .eln present in the back trace is the responsible, AFAICS those are:
> > bytecomp.el, mule.el, startup.el (with the first being the suspect nr1).
> 
> I also use Emacs with the same configuration on a Linux system and it
> has never crashed while I have been experiencing frequent crashes on
> Windows. I think it is not reproducible on Linux.
> 
> I have tried to build Emacs with native-compilation on and added a
> file-local prop-line in consult.el setting `native-comp-speed` to 1. The
> eln cache produced does not trigger the crash. After setting the
> file-local property `native-comp-spped` back to 2, I easily reproduced
> the crash. Does this indicate that the miscompiled code is inside
> consult.el?

It could, but see what Andrea wrote above: it could also be the fault
of a few other packages involved in this.

So please build Emacs with those 3 packages (bytecomp.el, mule.el,
startup.el) natively-compiled with native-comp-speed = 1, then
native-compile consult.el with native-comp-speed = 2, and see if you
still see the crashes.  If yes, then consult.el is probably the one
that triggers the bug.  If compiling those 3 other packages with
native-comp-speed = 1 eliminates the crashes, then we need to look for
the one of those 3 which triggers the crash, and continue narrowing
this down from there.

> I try to find out the minimal code that can reproduce the issue by
> starting an Emacs instance with the -Q option. Then I copy the
> definition of `consult-buffer` into this instance and evaluate it. If
> there is an error, such as missing definition, I try to fix the error by
> copying more code and evaluating them. Finally I reached a point that
> `consult-buffer` can be executed with no error reported. However, when I
> save all copied code to an el file and load it with a clean Emacs (with
> -Q option) then I evaluate the buffer and execute `consult-buffer` there
> is an error! I have tried this process twice: copying any required code
> and execute them piece by piece until `consult-buffer` can be executed
> correctly, saving the whole code as an el file then trying to evaluate
> it with another clean Emacs instance, it always fails to execute
> `consult-buffer` after I evaluate the whole buffer all at once. I have
> no idead why this happens since I know not much about emacs lisp.

What is the error you see after you evaluate the whole code?  It might
be that the order of the code in the el file matters, and you need to
reorder the functions and variables there.

But I think finding the minimal Lisp code which, when native-compiled
with native-comp-speed = 2, triggers the crashes is more important.

Thanks.