Subject: bug#38564: 27.0.50; macOS "emacs -nw" git-gutter-mode segfault

From: Mike Hamrick <[email-masked]>
Date: Thu, 19 Dec 2019 10:03:53 -0800

Heya folks,

I believe I'm still experiencing a version of this same bug. I'm not
always able to reproduce it unfortunately, but it often happens when
viewing git logs in Magit with 'll'. Again, terminal frame with the 'ns'
version of emacs 27.

In GNU Emacs 27.0.50 (build 6, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G2022))
 of 2019-12-18 built on st-mikeh1
Repository revision: d55f2f74f53910c4416be1e023771dc3a8142727
Repository branch: master
System Description:  Mac OS X 10.14.6

Here's my stack trace:

frame #0: 0x0000000104038b3e Emacs`ns_lookup_indexed_color(idx=18446744073709551613, f=0x00007fb0c801ae10) at nsterm.m:2097:64
   2094 NSColor *
   2095 ns_lookup_indexed_color (unsigned long idx, struct frame *f)
   2096 {
-> 2097   struct ns_color_table *color_table = FRAME_DISPLAY_INFO (f)->color_table;
   2098   if (idx < 1 || idx >= color_table->avail)
   2099     return nil;
   2100   return color_table->colors[idx];
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xffffffff00000044)
  * frame #0: 0x0000000104038b3e Emacs`ns_lookup_indexed_color(idx=18446744073709551613, f=0x00007fb0c801ae10) at nsterm.m:2097:64
    frame #1: 0x0000000104039615 Emacs`ns_color_index_to_rgba(idx=-3, f=0x00007fb0c801ae10) at nsterm.m:2301:13
    frame #2: 0x0000000103d576f3 Emacs`extend_face_to_end_of_line(it=0x00007ffeebf29110) at xdisp.c:21896:7
    frame #3: 0x0000000103d25afa Emacs`display_line(it=0x00007ffeebf29110, cursor_vpos=4) at xdisp.c:23478:4
    frame #4: 0x0000000103d2294b Emacs`try_window(window=0x00007fb09aa19705, pos=(charpos = 1, bytepos = 1), flags=1) at xdisp.c:19005:11
    frame #5: 0x0000000103d6112f Emacs`redisplay_window(window=0x00007fb09aa19705, just_this_one_p=false) at xdisp.c:18426:8
    frame #6: 0x0000000103d5f24d Emacs`redisplay_window_0(window=0x00007fb09aa19705) at xdisp.c:16147:5
    frame #7: 0x0000000103f2e83a Emacs`internal_condition_case_1(bfun=(Emacs`redisplay_window_0 at xdisp.c:16145), arg=0x00007fb09aa19705, handlers=0x0000000105fe3e9b, hfun=(Emacs`redisplay_window_error at xdisp.c:16138)) at eval.c:1379:25
    frame #8: 0x0000000103d5db3b Emacs`redisplay_windows(window=0x00007fb09aa19705) at xdisp.c:16127:4
    frame #9: 0x0000000103d5daea Emacs`redisplay_windows(window=0x00007fb09aa194f5) at xdisp.c:16121:2
    frame #10: 0x0000000103d1d2d2 Emacs`redisplay_internal at xdisp.c:15595:5
    frame #11: 0x0000000103d21349 Emacs`redisplay at xdisp.c:14822:3
    frame #12: 0x0000000103e379d5 Emacs`read_char(commandflag=1, map=0x00007fb0999ae4e3, prev_event=0x0000000000000000, used_mouse_menu=0x00007ffeebf3054f, end_time=0x0000000000000000) at keyboard.c:2488:6
    frame #13: 0x0000000103e337e9 Emacs`read_key_sequence(keybuf=0x00007ffeebf30850, prompt=0x0000000000000000, dont_downcase_last=false, can_return_switch_frame=true, fix_current_buffer=true, prevent_redisplay=false) at keyboard.c:9536:12
    frame #14: 0x0000000103e3220a Emacs`command_loop_1 at keyboard.c:1345:15
    frame #15: 0x0000000103f2e77f Emacs`internal_condition_case(bfun=(Emacs`command_loop_1 at keyboard.c:1236), handlers=0x0000000000000090, hfun=(Emacs`cmd_error at keyboard.c:919)) at eval.c:1355:25
    frame #16: 0x0000000103e49e9c Emacs`command_loop_2(ignore=0x0000000000000000) at keyboard.c:1091:11
    frame #17: 0x0000000103f2e0ea Emacs`internal_catch(tag=0x000000000000c870, func=(Emacs`command_loop_2 at keyboard.c:1087), arg=0x0000000000000000) at eval.c:1116:25
    frame #18: 0x0000000103e311b8 Emacs`command_loop at keyboard.c:1070:2
    frame #19: 0x0000000103e30ff0 Emacs`recursive_edit_1 at keyboard.c:714:9
    frame #20: 0x0000000103e31389 Emacs`Frecursive_edit at keyboard.c:786:3
    frame #21: 0x0000000103e2e801 Emacs`main(argc=3, argv=0x00007ffeebf30e08) at emacs.c:2054:3
    frame #22: 0x00007fff631363d5 libdyld.dylib`start + 1
    frame #23: 0x00007fff631363d5 libdyld.dylib`start + 1