Subject: bug#43973: 28.0.50; [NS] Two crashes on macOS

From: Andrii Kolomoiets <[email-masked]>
Date: Wed, 14 Oct 2020 11:50:29 +0300

Alan Third <[email-masked]> writes:

> modified   src/nsterm.m
> @@ -3048,6 +3048,9 @@ so some key presses (TAB) are swallowed by the system.  */
>        if (!face)
>          face = FRAME_DEFAULT_FACE (f);
>  
> +      if (!face)
> +        return;
> +
>        ns_focus (f, &frame_rect, 1);
>        [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), f) set];
>        for (int i = 0; i < 4 ; i++)
>
>
> "fixes" it, but leaves Emacs in a bit of a strange state where I can
> only see one frame and it's incredibly slow.

Was working in Emacs under lldb for almost two days to catch my random
crash and here it is:

Process 78804 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xc0)
    frame #0: 0x0000000100456e88 emacs`ns_clear_under_internal_border + 424
emacs`ns_clear_under_internal_border:
->  0x100456e88 <+424>: movq   0xc0(%rax), %rdi
    0x100456e8f <+431>: movq   -0x38(%rbp), %rsi
    0x100456e93 <+435>: callq  0x1004375a0               ; ns_lookup_indexed_color
    0x100456e98 <+440>: movq   0xce5a1(%rip), %rsi       ; "set"
Target 0: (emacs) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xc0)
  * frame #0: 0x0000000100456e88 emacs`ns_clear_under_internal_border + 424
    frame #1: 0x00000001000afe95 emacs`clear_garbaged_frames at xdisp.c:12110:17

Debug map object file for nsterm.o is ignored because it has changed, so
backtrace may be not so useful.

Going to work in Emacs under lldb with your patch applied to see if it
will crash again.

Thanks!