3

I've been experiencing a crash since upgrading to Emacs 26.1 and MacOS 10.13.4. It happens when running server-start (which is in my .emacs file), and a stale server auth file exists from a previous Emacs instance.

Reproducing it is easy:

  1. Start Emacs 26.1.
  2. Customive variable server-use-tcp; set value to t and save for future sessions.
  3. Run server-start.
  4. Copy the file server in the {server-auth-dir} folder to server-2.
  5. Quit Emacs.
  6. Rename server-2 file to server.
  7. Relaunch Emacs.
  8. Run server-start.
  9. Observe crash.

The crash log that I see is:

Process:               Emacs-x86_64-10_10 [54595]
Path:                  /Applications/Emacs.app/Contents/MacOS/Emacs-x86_64-10_10
Identifier:            org.gnu.Emacs
Version:               Version 26.1 (9.0)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Emacs-x86_64-10_10 [54595]
User ID:               501

Date/Time:             2018-06-15 11:11:33.871 -0600
OS Version:            Mac OS X 10.13.4 (17E199)
Report Version:        12
Anonymous UUID:        FAFB472E-6635-1BF9-3A87-39490D81E931

Sleep/Wake UUID:       62FC5A60-36B2-453C-832A-C3FD5AA072DE

Time Awake Since Boot: 180000 seconds
Time Since Wake:       12000 seconds

System Integrity Protection: disabled

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

Exception Type:        EXC_BAD_ACCESS (SIGABRT)
Exception Codes:       KERN_INVALID_ADDRESS at 0x000000000000003f
Exception Note:        EXC_CORPSE_NOTIFY

VM Regions Near 0x3f:
--> 
    __TEXT                 0000000100000000-0000000100233000 [ 2252K] r-x/rwx SM=COW  /Applications/Emacs.app/Contents/MacOS/Emacs-x86_64-10_10

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff654e5b6e __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff656b0080 pthread_kill + 333
2   libsystem_c.dylib               0x00007fff653f36fe raise + 26
3   Emacs-x86_64-10_10              0x00000001000c0a81 terminate_due_to_signal + 161
4   Emacs-x86_64-10_10              0x00000001000dde43 emacs_abort + 19
5   Emacs-x86_64-10_10              0x00000001001c4a0c ns_term_shutdown + 124
6   Emacs-x86_64-10_10              0x00000001000c0c55 shut_down_emacs + 261
7   Emacs-x86_64-10_10              0x00000001000c0a46 terminate_due_to_signal + 102
8   Emacs-x86_64-10_10              0x00000001000df736 deliver_fatal_thread_signal + 134
9   Emacs-x86_64-10_10              0x00000001000e0b8a handle_sigsegv + 170
10  libsystem_platform.dylib        0x00007fff656a3f5a _sigtramp + 26
11  ???                             000000000000000000 0 + 0
12  Emacs-x86_64-10_10              0x0000000100146a67 funcall_subr + 247
13  Emacs-x86_64-10_10              0x0000000100146114 Ffuncall + 740
14  Emacs-x86_64-10_10              0x00000001001888c8 exec_byte_code + 2248
15  Emacs-x86_64-10_10              0x00000001001460b5 Ffuncall + 645
16  Emacs-x86_64-10_10              0x00000001001888c8 exec_byte_code + 2248
17  Emacs-x86_64-10_10              0x00000001001460b5 Ffuncall + 645
18  Emacs-x86_64-10_10              0x000000010013f846 Ffuncall_interactively + 70
19  Emacs-x86_64-10_10              0x0000000100146114 Ffuncall + 740
20  Emacs-x86_64-10_10              0x00000001001410ff Fcall_interactively + 6303
21  Emacs-x86_64-10_10              0x0000000100146a8b funcall_subr + 283
22  Emacs-x86_64-10_10              0x0000000100146114 Ffuncall + 740
23  Emacs-x86_64-10_10              0x00000001001888c8 exec_byte_code + 2248
24  Emacs-x86_64-10_10              0x00000001001460b5 Ffuncall + 645
25  Emacs-x86_64-10_10              0x00000001001888c8 exec_byte_code + 2248
26  Emacs-x86_64-10_10              0x00000001001460b5 Ffuncall + 645
27  Emacs-x86_64-10_10              0x000000010013f846 Ffuncall_interactively + 70
28  Emacs-x86_64-10_10              0x0000000100146114 Ffuncall + 740
29  Emacs-x86_64-10_10              0x0000000100145c4f Fapply + 575
30  Emacs-x86_64-10_10              0x00000001001400ba Fcall_interactively + 2138
31  Emacs-x86_64-10_10              0x0000000100146a8b funcall_subr + 283
32  Emacs-x86_64-10_10              0x0000000100146114 Ffuncall + 740
33  Emacs-x86_64-10_10              0x00000001001888c8 exec_byte_code + 2248
34  Emacs-x86_64-10_10              0x00000001001460b5 Ffuncall + 645
35  Emacs-x86_64-10_10              0x00000001001466cd call1 + 45
36  Emacs-x86_64-10_10              0x00000001000c4b73 command_loop_1 + 1987
37  Emacs-x86_64-10_10              0x0000000100144907 internal_condition_case + 87
38  Emacs-x86_64-10_10              0x00000001000d59b0 command_loop_2 + 48
39  Emacs-x86_64-10_10              0x00000001001441ae internal_catch + 78
40  Emacs-x86_64-10_10              0x00000001000c3a5e command_loop + 158
41  Emacs-x86_64-10_10              0x00000001000c3982 recursive_edit_1 + 130
42  Emacs-x86_64-10_10              0x00000001000c3ba5 Frecursive_edit + 229
43  Emacs-x86_64-10_10              0x00000001000c25a2 main + 6370
44  libdyld.dylib                   0x00007fff65395015 start + 1

Thread 1:
0   libsystem_kernel.dylib          0x00007fff654e6292 __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff656ad20e _pthread_wqthread + 1552
2   libsystem_pthread.dylib         0x00007fff656acbe9 start_wqthread + 13

Thread 2:
0   libsystem_kernel.dylib          0x00007fff654e6292 __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff656ad20e _pthread_wqthread + 1552
2   libsystem_pthread.dylib         0x00007fff656acbe9 start_wqthread + 13

Thread 3:
0   libsystem_kernel.dylib          0x00007fff654e6292 __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff656ad20e _pthread_wqthread + 1552
2   libsystem_pthread.dylib         0x00007fff656acbe9 start_wqthread + 13

Thread 4:
0   libsystem_kernel.dylib          0x00007fff654e6292 __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff656ad20e _pthread_wqthread + 1552
2   libsystem_pthread.dylib         0x00007fff656acbe9 start_wqthread + 13

Thread 5:
0   libsystem_kernel.dylib          0x00007fff654e5cfa __select + 10
1   Emacs-x86_64-10_10              0x00000001001c605f -[EmacsApp fd_handler:] + 255
2   com.apple.Foundation            0x00007fff3f17d1f8 __NSThread__start__ + 1197
3   libsystem_pthread.dylib         0x00007fff656ad661 _pthread_body + 340
4   libsystem_pthread.dylib         0x00007fff656ad50d _pthread_start + 377
5   libsystem_pthread.dylib         0x00007fff656acbf9 thread_start + 13

Thread 6:
0   libsystem_pthread.dylib         0x00007fff656acbdc start_wqthread + 0
1   ???                             0x6e496d656d685373 0 + 7947003299866628979

Thread 7:
0   libsystem_pthread.dylib         0x00007fff656acbdc start_wqthread + 0
1   ???                             0x4058504320000000 0 + 4636544065607827456

Thread 8:: com.apple.NSEventThread
0   libsystem_kernel.dylib          0x00007fff654dc20a mach_msg_trap + 10
1   libsystem_kernel.dylib          0x00007fff654db724 mach_msg + 60
2   com.apple.CoreFoundation        0x00007fff3d0807d5 __CFRunLoopServiceMachPort + 341
3   com.apple.CoreFoundation        0x00007fff3d07fb27 __CFRunLoopRun + 1783
4   com.apple.CoreFoundation        0x00007fff3d07f1a3 CFRunLoopRunSpecific + 483
5   com.apple.AppKit                0x00007fff3a757fc4 _NSEventThread + 184
6   libsystem_pthread.dylib         0x00007fff656ad661 _pthread_body + 340
7   libsystem_pthread.dylib         0x00007fff656ad50d _pthread_start + 377
8   libsystem_pthread.dylib         0x00007fff656acbf9 thread_start + 13

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00007fff9d9c5380  rcx: 0x000000010063c8e8  rdx: 0x0000000000000000
  rdi: 0x0000000000000307  rsi: 0x0000000000000006  rbp: 0x000000010063c920  rsp: 0x000000010063c8e8
   r8: 0x000000000000007f   r9: 0x0000000100c29850  r10: 0x0000000000000000  r11: 0x0000000000000287
  r12: 0x0000000000000307  r13: 0x2000000000000000  r14: 0x0000000000000006  r15: 0x000000000000002d
  rip: 0x00007fff654e5b6e  rfl: 0x0000000000000286  cr2: 0x000000010063b868

Logical CPU:     0
Error Code:      0x02000148
Trap Number:     133
... snip ...

Full crash log here: https://gist.github.com/timcharper/098fab7860d81c52a9014dc6c8544edc

holocronweaver
  • 1,319
  • 10
  • 22
Tim Harper
  • 141
  • 4

1 Answers1

1

Here is a work-around that has worked for me:

;; server-start workaround
(defun ss-work-around/server-auth-file-name ()
  (format "%s/%s" server-auth-dir "server"))

(defun ss-work-around/server-port ()
  (let ((server-auth-filename (ss-work-around/server-auth-file-name)))
    (when (file-exists-p server-auth-filename)
      (with-temp-buffer
        (progn
          (insert-file-contents-literally server-auth-filename)
          (search-forward ":")
          (let ((start (point)))
            (search-forward " ")
            (buffer-substring-no-properties start (- (point) 1))))))))

(defun ss-work-around/port-is-reachable (port)
  (with-temp-buffer
    (let ((exit-status (shell-command (format "lsof -i :%s" server-port) (current-buffer) (current-buffer))))
      (eq 0 exit-status))))


(defun ss-work-around/remove-stale-server-auth-file ()
  (let ((server-port (ss-work-around/server-port)))
    (when (and
          server-port
          (not (ss-work-around/port-is-reachable server-port)))
      (message "Removing stale server file %s for port %s" (ss-work-around/server-auth-file-name) server-port)
      (delete-file (ss-work-around/server-auth-file-name)))) )

(ss-work-around/remove-stale-server-auth-file)
(server-start)
Tim Harper
  • 141
  • 4