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

From: Aaron Jensen <[email-masked]>
Date: Thu, 29 Dec 2022 18:46:54 -0500

On Thu, Dec 29, 2022 at 5:47 PM Aaron Jensen <[email-masked]> wrote:
>
> On Tue, Dec 27, 2022 at 8:11 AM Eli Zaretskii <[email-masked]> wrote:
> >
> > > From: Aaron Jensen <[email-masked]>
> > > Date: Tue, 27 Dec 2022 06:12:35 -0500
> > > Cc: [email-masked], [email-masked], [email-masked]
> > >
> > > I found a similar issue in another program:
> > > https://forum.xojo.com/t/xojo-2022r3-1-crashes-galore/72887/142
> >
> > Maybe, maybe not.  Your crashes always happen after restarting, right?
> > You don't see crashes inside dlopen if you never restart, correct?
> >
> > But yes, it could be something related.  My production session has 260
> > *.eln files loaded, for example.  So if macOS 13 has problems with
> > loading many shared libraries, maybe this is one of the symptoms.
>
> I can't say that with 100% certainty. Sometimes the crashes are hours
> after I started Emacs and I don't know if I had ever restarted that
> session. I do seem to be crashing a lot less frequently after the
> signal patch, which is probably just a coincidence, but who knows.
>
> Aaron

I just got a crash on a fresh start, so I now know it is not related
to restarts. Interestingly enough, this crash and the one just before
show the eln that is being loaded. The first time it was:

vc-hg-69e20438-d4ba19ca.eln

and the second time it was:

magit-status-6f9334e6-b672845f.eln

It seems to happen more often when I immediately start doing something
in Emacs. One thing of note is that I have something that eagerly
loads packages on an idle timer (it caches what was loaded when Emacs
is quit). That's possibly why there is usually a timer_event_handler
in the trace. I don't know if that gives us any clues as to what may
be happening here.

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Emacs [19874]
Path:                  /opt/homebrew/*/Emacs.app/Contents/MacOS/Emacs
Identifier:            org.gnu.Emacs
Version:               Version 29.0.60 (9.0)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2022-12-29 18:41:27.1385 -0500
OS Version:            macOS 13.1 (22C65)
Report Version:        12
Anonymous UUID:        CD1F31D7-5E61-2935-643D-55F58CD29C12

Sleep/Wake UUID:       FC867C11-7B4D-45DA-A2FF-FE03A9A69EF4

Time Awake Since Boot: 210000 seconds
Time Since Wake:       5671 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGABRT)
Exception Codes:       KERN_PROTECTION_FAILURE at 0x000000013b1940f8
Exception Codes:       0x0000000000000002, 0x000000013b1940f8

VM Region Info: 0x13b1940f8 is in 0x13b194000-0x13b1ac000;  bytes
after start: 248  bytes before end: 98055
      REGION TYPE                    START - END         [ VSIZE]
PRT/MAX SHRMOD  REGION DETAIL
      dyld private memory         13b154000-13b194000    [  256K]
rw-/rwx SM=PRV
--->  __TEXT                      13b194000-13b1ac000    [   96K]
r-x/rwx SM=COW  ...-b672845f.eln
      __DATA_CONST                13b1ac000-13b1b0000    [   16K]
r--/rwx SM=COW  ...-b672845f.eln

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib               0x1a6d621b0 __pthread_kill + 8
1   libsystem_pthread.dylib               0x1a6d98cec pthread_kill + 288
2   libsystem_c.dylib                     0x1a6c9aa50 raise + 32
3   Emacs                                 0x100d69aec
terminate_due_to_signal + 204
4   Emacs                                 0x100d6a2f0 emacs_abort + 20
5   Emacs                                 0x100d38db0 ns_term_shutdown + 132
6   Emacs                                 0x100c24b94 shut_down_emacs + 332
7   Emacs                                 0x100d69ab4
terminate_due_to_signal + 148
8   Emacs                                 0x100c47084 handle_fatal_signal + 16
9   Emacs                                 0x100c47100
deliver_thread_signal + 124
10  Emacs                                 0x100c45700
deliver_fatal_thread_signal + 12
11  libsystem_platform.dylib             0x1a6dc72a4 _sigtramp + 56
12  dyld                                 0x1a6a9c1b4
lsl::BTree<lsl::Allocator::Buffer,
lsl::PersistentAllocator::RegionSizeCompare, false>::NodeCore<15u,
10u>::splitChild(unsigned char, lsl::Allocator&) + 172
13  dyld                                 0x1a6a9c1b4
lsl::BTree<lsl::Allocator::Buffer,
lsl::PersistentAllocator::RegionSizeCompare, false>::NodeCore<15u,
10u>::splitChild(unsigned char, lsl::Allocator&) + 172
14  dyld                                 0x1a6a9bf78
lsl::BTree<lsl::Allocator::Buffer,
lsl::PersistentAllocator::RegionSizeCompare,
false>::const_iterator::prepareForInsertion(lsl::Allocator&) + 532
15  dyld                                 0x1a6a9bbb0
lsl::BTree<lsl::Allocator::Buffer,
lsl::PersistentAllocator::RegionSizeCompare,
false>::insert_internal(lsl::BTree<lsl::Allocator::Buffer,
lsl::PersistentAllocator::RegionSizeCompare, false>::const_iterator&&,
lsl::Allocator::Buffer&&) + 452
16  dyld                                 0x1a6a99a90
lsl::PersistentAllocator::reserveRange(lsl::BTree<lsl::Allocator::Buffer,
lsl::PersistentAllocator::RegionSizeCompare, false>::const_iterator&,
lsl::Allocator::Buffer) + 412
17  dyld                                 0x1a6a9a0b0
lsl::PersistentAllocator::allocate_buffer(unsigned long, unsigned
long, unsigned long, lsl::Allocator**) + 624
18  dyld                                 0x1a6a991e0
lsl::Allocator::aligned_alloc(unsigned long, unsigned long) + 180
19  dyld                                 0x1a6a99230
lsl::Allocator::strdup(char const*) + 48
20  dyld                                 0x1a6a968b8
dyld4::FileManager::fileRecordForPath(char const*) + 40
21  dyld                                 0x1a6ab4624
dyld4::Atlas::ProcessSnapshot::Serializer::readMappedFileInfo(std::__1::span<std::byte,
18446744073709551615ul>&, unsigned long long&, lsl::UUID&,
dyld4::FileRecord&) + 132
22  dyld                                 0x1a6ab3170
dyld4::Atlas::ProcessSnapshot::Serializer::deserialize(std::__1::span<std::byte,
18446744073709551615ul>) + 928
23  dyld                                 0x1a6ab2cec
dyld4::Atlas::ProcessSnapshot::ProcessSnapshot(lsl::Allocator&,
dyld4::FileManager&, bool, std::__1::span<std::byte,
18446744073709551615ul>) + 304
24  dyld                                 0x1a6a7ef64
lsl::UniquePtr<dyld4::Atlas::ProcessSnapshot>
lsl::Allocator::makeUnique<dyld4::Atlas::ProcessSnapshot,
lsl::EphemeralAllocator&, dyld4::FileManager&, bool,
std::__1::span<std::byte, 18446744073709551615ul>
const&>(lsl::EphemeralAllocator&, dyld4::FileManager&, bool&&,
std::__1::span<std::byte, 18446744073709551615ul> const&) + 80
25  dyld                                 0x1a6a7bafc
dyld4::RuntimeState::getCurrentProcessSnapshot() + 96
26  dyld                                 0x1a6a7b8cc
dyld4::RuntimeState::notifyDebuggerLoad(std::__1::span<dyld4::Loader
const*, 18446744073709551615ul> const&) + 72
27  dyld                                 0x1a6aaaf3c
dyld4::APIs::dlopen_from(char const*, int, void*)::$_0::operator()()
const + 748
28  dyld                                 0x1a6aa4968
dyld4::APIs::dlopen_from(char const*, int, void*) + 892
29  Emacs                                 0x100cecdb0 Fnative_elisp_load + 356
30  Emacs                                 0x100cc888c Fload + 2104
31  Emacs                                 0x100cca5f0 save_match_data_load + 92
32  Emacs                                 0x100ca4928
load_with_autoload_queue + 120
33  Emacs                                 0x100cb0d84 Frequire + 560
34  Emacs                                 0x100ca0a30 eval_sub + 2236
35  Emacs                                 0x100ca3158
internal_lisp_condition_case + 884
36  Emacs                                 0x100ca089c eval_sub + 1832
37  Emacs                                 0x100ca0bac Fprogn + 48
38  Emacs                                 0x100ca23a8 Fwhile + 80
39  Emacs                                 0x100ca089c eval_sub + 1832
40  Emacs                                 0x100ca0bac Fprogn + 48
41  Emacs                                 0x100ca610c funcall_lambda + 1316
42  Emacs                                 0x100ca2724 Ffuncall + 316
43  Emacs                                 0x100ca2724 Ffuncall + 316
44  timer-3ee7cfd9-d55357b5.eln           0x107b40e44
F74696d65722d6576656e742d68616e646c6572_timer_event_handler_0 + 832
45  Emacs                                 0x100ca2724 Ffuncall + 316
46  Emacs                                 0x100c31288 timer_check + 892
47  Emacs                                 0x100c2f634 readable_events + 36
48  Emacs                                 0x100c30eb4 get_input_pending + 56
49  Emacs                                 0x100c2f364
detect_input_pending_run_timers + 48
50  Emacs                                 0x100cf7064
wait_reading_process_output + 3824
51  Emacs                                 0x100b6d4d8 sit_for + 376
52  Emacs                                 0x100c2ca74 read_char + 6756
53  Emacs                                 0x100c29548 read_key_sequence + 1056
54  Emacs                                 0x100c27db8 command_loop_1 + 700
55  Emacs                                 0x100ca332c
internal_condition_case + 96
56  Emacs                                 0x100c27ae8 command_loop_2 + 52
57  Emacs                                 0x100ca2d50 internal_catch + 88
58  Emacs                                 0x100d69f18 command_loop.cold.1 + 80
59  Emacs                                 0x100c27488 command_loop + 152
60  Emacs                                 0x100c27344 recursive_edit_1 + 148
61  Emacs                                 0x100c275a8 Frecursive_edit + 264
62  Emacs                                 0x100c26924 main + 7484
63  dyld                                 0x1a6a6fe50 start + 2544