Subject: bug#75459: 31.0.50; scratch-igc: Breakpoint 1, terminate_due_to_signal (sig=sig@entry=6, backtrace_limit=backtrace_limit@entry=2147483647) at ./src/emacs.c:432

From: Eli Zaretskii <[email-masked]>
Date: Fri, 10 Jan 2025 09:53:11 +0200

> From: Gerd Möllmann <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked]
> Date: Fri, 10 Jan 2025 08:29:21 +0100
> 
> Could the problem then perhaps be barriers? In emacs_lldb.py I have, for
> LLDB, a command
> 
>   def xpostmortem(debugger, command, ctx, result, internal_dict):
>       """Call igc_postmortem to set MPS arena to postmortem state"""
>       debugger.HandleCommand(f"expr igc_postmortem()")
> 
> I call that command manually when MPS gets in the way. Here is the
> description from MPS

Maybe.  We could add that to the xbacktrace command.  However,...

> In the postmortem state, incremental collection does not take place,
> objects do not move in memory, references do not change, the staleness
> of location dependencies does not change, and memory occupied by
> unreachable objects is not recycled. Additionally, all memory protection
> is removed, and memory may be in an inconsistent state.
> 
> Warning
> 
> After calling this function, memory managed by the arena is not in a
> consistent state, and so it is no longer safe to continue running the
> client program. This function is intended for postmortem debugging only.
> This function must be called from the thread that holds the arena lock
> (if any thread holds it). This is the case if the program is
> single-threaded, or if it is called from an MPS assertion handler. When
> calling this function from the debugger, check the stack to see which
> thread has the MPS arena lock.

...the above makes me wonder whether calling this unconditionally will
shoot us in the foot.  Debugging with GDB does sometimes call
functions in the debuggee, whereas the above says "no longer safe to
continue running the client program".  I wonder what kind of
"postmortem debugging" they had in mind, perhaps only debugging
MPS-related code itself?

In any case, we should call this function only once per run, and in
the context of thread 1.

So maybe calling it manually, like you do now, is the best
alternative?  In which case we should add this to etc/DEBUG, I think.