Subject: bug#60220: 29.0.60; macOS 13.1 crash shortly after starting Emacs

From: Aaron Jensen <[email-masked]>
Date: Tue, 20 Dec 2022 10:59:20 -0500

On Tue, Dec 20, 2022 at 10:40 AM Eli Zaretskii <[email-masked]> wrote:
>
> > From: Aaron Jensen <[email-masked]>
> > Date: Tue, 20 Dec 2022 10:25:39 -0500
> >
> > Here is another trace I just got during a restart. It's slightly
> > different. This one seems to point to rng-loc at least as part of the
> > trace.
>
> AFAIU, it says that Emacs was _loading_ rng-loc.  That doesn't mean
> the problem is in rng-loc's code.  The fatal signal comes from the
> maxOS implementation of dlopen, so I suspect that the way we restart
> Emacs messes up some OS data structures regarding loaded shared
> libraries or something.
>
> Note that the previous crash you posted also crashes inside dlopen.
>
> So I think it's safe to say that restarting Emacs makes loading of
> *.eln files (and maybe share libraries in general) fragile and tending
> to crash, for some reason.  Maybe we should explicitly unload all the
> *.eln files when we restart?

Interesting. If I restart while launched from lldb, I get the below.
It happens right away and it doesn't actually restart. This is not the
behavior I see if I launch it normally or in xcode. I should note that
occasionally when I restart Emacs it just quits and does not restart.
I have to restart it manually. Perhaps this is all connected to the
issue you're suggesting.

(lldb) process launch
Process 19414 launched: 'src/emacs' (arm64)
Process 19414 stopped
* thread #8, stop reason = exec
    frame #0: 0x0000000100b2c950 dyld`_dyld_start
dyld`:
->  0x100b2c950 <+0>:  mov    x0, sp
    0x100b2c954 <+4>:  and    sp, x0, #0xfffffffffffffff0
    0x100b2c958 <+8>:  mov    x29, #0x0
    0x100b2c95c <+12>: mov    x30, #0x0
Target 0: (emacs) stopped.
(lldb) thread list
Process 19414 stopped
* thread #8: tid = 0x3026c, 0x0000000100b2c950 dyld`_dyld_start, stop
reason = exec
(lldb) thread backtrace
* thread #8, stop reason = exec
  * frame #0: 0x0000000100b2c950 dyld`_dyld_start
(lldb) continue
Process 19414 resuming
Process 19414 exited with status = 14 (0x0000000e) Terminated due to signal 14