Subject: Re: bug#78738: (signal nil 5) crashes Emacs

From: Daniel Colascione <[email-masked]>
Date: Mon, 09 Jun 2025 23:43:17 -0700

Pip Cet <[email-masked]> writes:

> "Daniel Colascione" <[email-masked]> writes:
>
>> (signal nil 5) crashes Emacs
>
> Good catch!
>
> This would fix it, right?
>
> diff --git a/src/eval.c b/src/eval.c
> index fbb881d682d..be6d1a0a9ac 100644
> --- a/src/eval.c
> +++ b/src/eval.c
> @@ -1888,7 +1888,7 @@ DEFUN ("signal", Fsignal, Ssignal, 2, 2, 0,
>    (Lisp_Object error_symbol, Lisp_Object data)
>  {
>    /* If they call us with nonsensical arguments, produce "peculiar error".  */
> -  if (NILP (error_symbol) && NILP (data))
> +  if (NILP (error_symbol) && !CONSP (data))
>      error_symbol = Qerror;
>    signal_or_quit (error_symbol, data, false);
>    eassume (false);
>
> Note that there are currently many ways to crash Emacs by executing
> dodgy Elisp; I think there should be fewer, but others appear to
> disagree.  We specifically added an eassert to crash Emacs when a Lisp
> function returns invalid data, for example.

Yeah, that should work.  The general theme of Fsignal seems to be
turning random passed-in stuff into a "peculiar error", so it seems
appropriate that it do the same for this specific set of parameters,
especially since the nil error_symbol behavior isn't documented.