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

From: Andrea Corallo <[email-masked]>
Date: Thu, 04 Jan 2024 04:51:26 -0500

Chang Xiaoduan <[email-masked]> writes:

> Andrea Corallo <[email-masked]> writes:
>
>>
>> There could be some function generated by macros without the speed
>> declaration?  Dunno...
>>
>> Anyway please try the opposite strategy (CU at speed 2 and functions at
>> speed 1) to narrow the function and let us know if it's more successful.
>>
>> Thanks
>>
>>   Andrea
>
> Hello,
>
> I just confirmed that when Emacs is built with `native-comp-speed' set
> to 2 and only `consult-buffer' has the form `(declare (speed 1))`, I can
> still reproduce the crash.

Okay then `consult-buffer' is not the misscompiled culprit.

> However, when all `defun', `defmacro',
> `cl-defun' and `defsubst' get the form `(declare (speed 1))`, then the
> crash can not be reproduced.

That's in line with the fact that you observed that compiling the whole
file at speed 1 does not trigger the bug.

> Before I investigate further, I am
> wondering that is that only one function responsible to the crash?

>From what you observed `consult-buffer' is not the problematic one.

> Is it
> possible that when 2 or more certain functions get compiled with
> `native-comp-speed' set to 2 that the crash can be reproduced?

It should not be the case, the only interactions we might observe is
between defmacro/defsubst and functions.

> If this
> is ture, then I think mannually add declare forms to functions is some
> how impossible to find the combination of such functions.

See previous point, but anyway I think adding declarations only defun is
a good start.

Thanks

  Andrea