Subject: Re: bug#62504: 30.0.50; SEGFAULT On M-x

From: Jacob Faibussowitsch <[email-masked]>
Date: Wed, 29 Mar 2023 08:29:06 -0400

Looks like I jumped the gun on blaming the segfaults on 52b67740d10df8ca539fdc2c7d50283997683141. They still happen before it. Interestingly they only appear to happen if the `(wrong-number-of-arguments #<subr signal> 2)` error has not fired.

For example, my setup lazy-loads many packages (among them yasnippet and auto-complete) on an idle timer or eagerly if I invoke/reference an auto-loaded symbol. If I wait for the idle timer to lazy load e.g. yasnippet then I get `(wrong-number-of-arguments #<subr signal> 2)`. But if I try to eagerly load yasnippet via auto-load then I get a segfault instead.

I don’t know how to reliably reproduce this unfortunately...

Best regards,

Jacob Faibussowitsch
(Jacob Fai - booss - oh - vitch)

> On Mar 29, 2023, at 04:49, Andrea Corallo <[email-masked]> wrote:
> 
> Eli Zaretskii <[email-masked]> writes:
> 
>>> From: Jacob Faibussowitsch <[email-masked]>
>>> Date: Tue, 28 Mar 2023 11:25:49 -0400
>>> 
>>> This bug is twofold and appears to be related to bug#62446 and bug#61917. I produce a much smaller reproducer that generates the same kind of error as bug#61917, namely `(wrong-number-of-arguments #<subr signal> 2)`. Segfaults only occur after the following commit:
>>> 
>>> commit 52b67740d10df8ca539fdc2c7d50283997683141
>>> Author: Mattias Engdegård <[email-masked]>
>>> Date:   Sat Mar 25 15:38:00 2023 +0100
>>> 
>>>    Generalise a LAP optimisation rule
>>> 
>>>    * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode):
>>>    Accept (stack-set 1) as equivalent to (discardN-preserve-tos 1) in a
>>>    rule previously overlooked.  This is usually beneficial in code size
>>>    and almost always shortens dynamic paths.
>>> 
>>> 
>>> Common setup:
>>> 
>>> 1. mkdir repro
>>> 2. Put attached init.el and main.c inside (technically, main.c need not be in repro)
>>> 
>>> ———
>>> 
>>> To reproduce bug#61917:
>>> 
>>> 1. git checkout master
>>> 2. configure --with-native-compilation \
>>>  --without-x \
>>>  --without-ns \
>>>  --without-compress-install \
>>>  --with-native-compilation \
>>>  --with-json \
>>>  --with-tree-sitter
>>> 3. make bootstrap
>>> 4. emacs  --init-directory ../repro
>>> 5. Check messages, and ye shall find the bug message.
>>> 
>>> ——— 
>>> 
>>> To reproduce segfault:
>>> 
>>> 1. git checkout 52b67740d10df8ca539fdc2c7d50283997683141
>>> 2. Perform same configure and build commands as above.
>>> 3. emacs --init-directory ../repro ../repro/main.c (loading main.c is *required*, the segfault does not fire otherwise)
>>> 4. (In emacs) M-x
>>> 5. Fatal error 11: Segmentation fault
>> 
>> Thanks.
>> 
>> Andrea, maybe this will help you investigate the issue.
> 
> Yep, noted thanks.
> 
>  Andrea