Subject: Re: bug#55269: 29.0.50; Infinite recursion causes segmentation fault

From: Lars Ingebrigtsen <[email-masked]>
Date: Thu, 05 May 2022 12:55:38 +0200

Philip Kaludercic <[email-masked]> writes:

> #12 0x0000000000686c42 in print_error_message (data=0x1fc6273, stream=0x7ffff4881285, context=0x0, caller=0x0) at print.c:957
> #13 0x0000000000686978 in Ferror_message_string (obj=0x1fc6273) at print.c:902
> #14 0x00000000006569f5 in skip_debugger (conditions=0x7ffff44534b3, data=0x1fc6273) at eval.c:1888

Hm...  so the backtrace here seems to say that skip_debugger (which is
supposed to be a predicate) is itself bugging out (i.e., the
Ferror_message_string is erroring)?

Hm...  Oh, it's coming from here?

void
print_error_message (Lisp_Object data, Lisp_Object stream, const char *context,
		     Lisp_Object caller)
[...]
      if (!NILP (Ffboundp (Qsubstitute_command_keys)))
	errmsg = call1 (Qsubstitute_command_keys, errmsg);

I think the fix here would be to ensure that that call never signals an
error (i.e., slap a condition-case around that call1).  I.e., could you
try this patch and see whether it fixes the problem?

diff --git a/src/print.c b/src/print.c
index 54d8bdfa3d..5255ea3632 100644
--- a/src/print.c
+++ b/src/print.c
@@ -954,7 +954,11 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context,
       errmsg = Fget (errname, Qerror_message);
       /* During loadup 'substitute-command-keys' might not be available.  */
       if (!NILP (Ffboundp (Qsubstitute_command_keys)))
-	errmsg = call1 (Qsubstitute_command_keys, errmsg);
+	{
+	  Lisp_Object subs = safe_call1 (Qsubstitute_command_keys, errmsg);
+	  if (!NILP (subs))
+	    errmsg = subs;
+	}
 
       file_error = Fmemq (Qfile_error, error_conditions);
     }

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no