I've been experiencing a weird problem. Ever since updating to catalina my emacs crashes at random intervals. It seems that there is no rule (or I cannot see it) to when it happens. The frequency is quite high but there is no specific thing I do before it happens. I have tried removing parts of my config which could be responsible but so far no matter what I remove it keeps on happening. I tried different versions of emacs: emacs for mac OS, emacs installed via homebrew and I'm now using a version I built myself, on all those versions the problem persists.

It is probably unrelated but when using neotree the color higlight on cursor hover lags behind the cursor - it should ever only higlight the filename the cursor currently hovers over but instead it also highlight the ones it hover over previously.

Below is the stack trace from the crash. Any help would be appreciated.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff6ab1c49a __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff6abd96cb pthread_kill + 384
2   libsystem_c.dylib               0x00007fff6aa343a2 raise + 26
3   org.gnu.Emacs                   0x000000010d6bd319 terminate_due_to_signal + 153
4   org.gnu.Emacs                   0x000000010d6bdc5b emacs_abort + 15
5   org.gnu.Emacs                   0x000000010d685bf0 ns_term_shutdown + 80
6   org.gnu.Emacs                   0x000000010d57bab4 shut_down_emacs + 340
7   org.gnu.Emacs                   0x000000010d6bd2e6 terminate_due_to_signal + 102
8   org.gnu.Emacs                   0x000000010d59acae 0x10d4bd000 + 908462
9   libsystem_platform.dylib        0x00007fff6abceb1d _sigtramp + 29
10  ???                             000000000000000000 0 + 0
11  com.apple.CoreFoundation        0x00007fff334f436b __CFRunLoopServiceMachPort + 322
12  com.apple.CoreFoundation        0x00007fff334f3907 __CFRunLoopRun + 1695
13  com.apple.CoreFoundation        0x00007fff334f2fe3 CFRunLoopRunSpecific + 499
14  com.apple.HIToolbox             0x00007fff3207a67d RunCurrentEventLoopInMode + 292
15  com.apple.HIToolbox             0x00007fff3207a3bd ReceiveNextEventCommon + 600
16  com.apple.HIToolbox             0x00007fff3207a147 _BlockUntilNextEventMatchingListInModeWithFilter + 64
17  com.apple.AppKit                0x00007fff306ff864 _DPSNextEvent + 990
18  com.apple.AppKit                0x00007fff306fe5d4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
19  com.apple.AppKit                0x00007fff306f8d76 -[NSApplication run] + 658
20  org.gnu.Emacs                   0x000000010d685dad 0x10d4bd000 + 1871277
21  org.gnu.Emacs                   0x000000010d684a11 ns_select + 897
22  org.gnu.Emacs                   0x000000010d654292 wait_reading_process_output + 3570
23  org.gnu.Emacs                   0x000000010d4c4f08 sit_for + 312
24  org.gnu.Emacs                   0x000000010d5841c6 read_char + 5222
25  org.gnu.Emacs                   0x000000010d5811da 0x10d4bd000 + 803290
26  org.gnu.Emacs                   0x000000010d57f9dc command_loop_1 + 1308
27  org.gnu.Emacs                   0x000000010d6065d7 internal_condition_case + 263
28  org.gnu.Emacs                   0x000000010d58fa80 0x10d4bd000 + 862848
29  org.gnu.Emacs                   0x000000010d605deb internal_catch + 267
30  org.gnu.Emacs                   0x000000010d6bd6e5 0x10d4bd000 + 2098917
31  org.gnu.Emacs                   0x000000010d57eac3 0x10d4bd000 + 793283
32  org.gnu.Emacs                   0x000000010d57e9f3 recursive_edit_1 + 115
33  org.gnu.Emacs                   0x000000010d57ec4b Frecursive_edit + 347
34  org.gnu.Emacs                   0x000000010d57d827 main + 7431
35  libdyld.dylib                   0x00007fff6a9cd2e5 start + 1
  • 1
    Back in the days when I first started using Emacs several users ago, I submitted an Emacs bug report with something that looked similar to your crash reporter log. The lead developer of the OSX port at the time explained to me that these types crash reports are not helpful to the Emacs team for debugging purposes. In a nutshell, the way to properly handle this is to build Emacs from source, then CD over to the Emacs src build directory in the terminal and then launch gdb .../nextstep/Emacs.app/Contents/MacOS/Emacs. When a crash occurs, type bt for backtrace. lldb works similarly. – lawlist Dec 7 '19 at 23:36
  • Thank you I will do that when I have a moment. In the meantime I just wanted to see if anyone else experienced that. I would assume if it's an emacs thing then it should happen to more people. If it's just my config then there is no need to report it to the developers. I will try running emacs without any config as well but due to the seemingly random nature of those crashes it is kind of difficult to get them to happen. – ramkick Dec 8 '19 at 20:46
  • I'm having the same issue. I've traced it to a bad interaction with iCloud Drive folders - like Documents by default. Moving all files you use in emacs outside iCloud Drive folders will solve the issue. The underlying problem seems to be a Mach port leak. macOS uses Mach ports for most IPC, including syscall. Opening files on iCloud Drive in emacs uses thousands of ports per file. If you want to see this open Activity Monitor and turn on the # Ports column. It might take a minute to show up, but it'll just keep climbing as you open files inside iCloud Drive. Eventually the system runs out of – sitharus Dec 12 '19 at 20:31
  • Interesting observation. It can certainly be connected. I did some tests with activity monitor and I see an increase in ports and memory usage as I open files from iCloud Drive. However I have opened a large number of files and the crash still hasn't occured. I remember several times the crash occured without me opening more than 10 files. This makes me question if this is the cause. I installed the new system update so perhaps something causing the crash got fixed. Can you give more info on how the crash occured in your case, eg. after how many files and so on? Also your last message was cut. – ramkick Dec 13 '19 at 22:30
  • 1
    Rather than discuss it here with other users, I strongly recommend you M-x report-emacs-bug so you can investigate it with the developers who can then try and fix it once and for all. – Stefan Dec 15 '19 at 0:12

The Emacs macOS port maintainers have found a work-around, but the problem seems to be deep inside macOS. See this bug report for details and a patch: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=38618

Hopefully this will make its way into the macOS releases soon, but for now you can do a local build and apply the patch. On 10.15 you'll need to export LIBXML2_CFLAGS="-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2" before running ./configure for the build to work.

| improve this answer | |
  • Thanks! this worked for me. – ramkick Dec 18 '19 at 11:43
  • Running on Catalina (10.15.5) the export seems to have done the trick for me as well. Thank you so much. – Ashton Wiersdorf Jul 23 at 1:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.