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

From: Aaron Jensen <[email-masked]>
Date: Thu, 22 Dec 2022 21:22:38 -0500

On Thu, Dec 22, 2022 at 9:06 PM Paul Eggert <[email-masked]> wrote:
>
> On 12/22/22 00:18, Eli Zaretskii wrote:
> > Paul, could you perhaps audit the code which implements restart-emacs,
> > and see if we need to make it safer, in particular wrt signals and
> > *.eln files loaded via dynlib.
>
> I don't offhand see why anything would need to be done other than turn
> off timer signals to the execed process. Something like the attached
> patch, perhaps. Aaron, could you give it a try?

Thank you, this certainly changes things. I don't get the sig 14
anymore in the debugger and it successfully restarts every time while
in the debugger. I will try using it for a while and see how that
goes.

I don't know if this is significant or not, but when I restart an
Emacs run from the terminal, or in the debugger, I see "Task policy
set failed: 4 ((os/kern) invalid argument)" printed to stderr.

(lldb) process launch
Process 13113 launched: 'src/emacs' (arm64)
Process 13113 stopped
* thread #8, stop reason = exec
    frame #0: 0x0000000100934950 dyld`_dyld_start
dyld`:
->  0x100934950 <+0>:  mov    x0, sp
    0x100934954 <+4>:  and    sp, x0, #0xfffffffffffffff0
    0x100934958 <+8>:  mov    x29, #0x0
    0x10093495c <+12>: mov    x30, #0x0
Target 0: (emacs) stopped.
(lldb) thread list
Process 13113 stopped
* thread #8: tid = 0x37d5ee, 0x0000000100934950 dyld`_dyld_start, stop
reason = exec
(lldb) continue
Process 13113 resuming
2022-12-22 21:09:48.439039-0500 emacs[13113:3659246] [assertion] Error
acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2
"Specified target process does not exist"
UserInfo={NSLocalizedFailureReason=Specified target process does not
exist}>
2022-12-22 21:09:48.439086-0500 emacs[13113:3659246] [process] Failed
to acquire AppNap adapter assertion with error Error
Domain=RBSAssertionErrorDomain Code=2 "Specified target process does
not exist" UserInfo={NSLocalizedFailureReason=Specified target process
does not exist}
2022-12-22 21:09:48.439102-0500 emacs[13113:3659246] Task policy set
failed: 4 ((os/kern) invalid argument)