Subject: bug#44349: 28.0.50; Assertion failure on macOS when resizing frame

From: Philipp <[email-masked]>
Date: Sat, 31 Oct 2020 16:51:41 +0100

1. Compile Emacs with assertions enabled on macOS.
2. Start it in graphical mode.
3. Try to resize the frame by dragging the lower-right corner.

This will trigger an assertion failure

doprnt.c:493: Emacs fatal error: assertion failed: ASCII_CHAR_P (fmtchar)
Fatal error 6: Aborted
Abort trap: 6

LLDB backtrace:

doprnt.c:493: Emacs fatal error: assertion failed: ASCII_CHAR_P (fmtchar)
Process 21775 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fff71cda33a libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
->  0x7fff71cda33a <+10>: jae    0x7fff71cda344            ; <+20>
    0x7fff71cda33c <+12>: movq   %rax, %rdi
    0x7fff71cda33f <+15>: jmp    0x7fff71cd4629            ; cerror_nocancel
    0x7fff71cda344 <+20>: retq   
Target 0: (emacs) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff71cda33a libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff71d96e60 libsystem_pthread.dylib`pthread_kill + 430
    frame #2: 0x00007fff71bf193e libsystem_c.dylib`raise + 26
    frame #3: 0x0000000100bcae19 emacs`terminate_due_to_signal(sig=<unavailable>, backtrace_limit=<unavailable>) at emacs.c:408:3 [opt]
    frame #4: 0x0000000100bcb42d emacs`emacs_abort at sysdep.c:2280:3 [opt]
    frame #5: 0x0000000100aaab36 emacs`ns_term_shutdown(sig=6) at nsterm.m:5729:7 [opt]
    frame #6: 0x00000001005c7634 emacs`shut_down_emacs(sig=<unavailable>, stuff=<unavailable>) at emacs.c:2472:3 [opt]
    frame #7: 0x0000000100bcad30 emacs`terminate_due_to_signal(sig=6, backtrace_limit=<unavailable>) at emacs.c:391:11 [opt]
    frame #8: 0x0000000100bcb9d9 emacs`die(msg=<unavailable>, file=<unavailable>, line=<unavailable>) at alloc.c:7341:3 [opt]
    frame #9: 0x00000001009acf6f emacs`doprnt(buffer=<unavailable>, bufsize=9223372036854775797, format=<unavailable>, format_end=<unavailable>, ap=<unavailable>) at doprnt.c:493:4 [opt]
    frame #10: 0x00000001009adcfc emacs`esprintf(buf="*scratch*  ??????????????????????????????????????", format=<unavailable>) at doprnt.c:535:12 [opt]
    frame #11: 0x0000000100abc0d5 emacs`-[EmacsView windowWillResize:toSize:](self=<unavailable>, _cmd=<unavailable>, sender=<unavailable>, frameSize=<unavailable>) at nsterm.m:7286:2 [opt]
    frame #12: 0x00007fff34ed2737 AppKit`-[NSWindow _confirmSize:force:] + 323
    frame #13: 0x00007fff3581d006 AppKit`-[NSWindow(NSWindowResizing) _validFrameForFrame:resizedFromEdge:] + 94
    frame #14: 0x00007fff35176b8d AppKit`-[NSTitledFrame _validFrameForResizeFrame:fromResizeEdge:] + 425
    frame #15: 0x00007fff3581cf68 AppKit`-[NSWindow(NSWindowResizing) _commonValidFrameForResizeFrame:fromResizeEdge:] + 157
    frame #16: 0x00007fff35819cd5 AppKit`-[NSWindow(NSWindowResizing) _frame:resizedFromEdge:withDelta:withEvent:withState:] + 3531
    frame #17: 0x00007fff35176065 AppKit`-[NSWindow(NSWindowResizing) _resizeWithEvent:] + 2486
    frame #18: 0x00007fff3504bfe6 AppKit`-[NSTitledFrame attemptResizeWithEvent:] + 177
    frame #19: 0x00007fff3504bcc7 AppKit`-[NSThemeFrame handleMouseDown:] + 294
    frame #20: 0x00007fff350e9248 AppKit`-[NSThemeFrame mouseDown:] + 30
    frame #21: 0x00007fff34fce5f0 AppKit`-[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4914
    frame #22: 0x00007fff34f38e21 AppKit`-[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2612
    frame #23: 0x00007fff34f381c9 AppKit`-[NSWindow(NSEventRouting) sendEvent:] + 349
    frame #24: 0x00007fff34f36554 AppKit`-[NSApplication(NSEvent) sendEvent:] + 352
    frame #25: 0x0000000100aab8e5 emacs`-[EmacsApp sendEvent:](self=<unavailable>, _cmd=<unavailable>, theEvent=<unavailable>) at nsterm.m:5902:3 [opt]
    frame #26: 0x00007fff34d835bf AppKit`-[NSApplication run] + 707
    frame #27: 0x0000000100aab09a emacs`-[EmacsApp run](self=<unavailable>, _cmd=<unavailable>) at nsterm.m:5771:9 [opt]
    frame #28: 0x0000000100aa67ee emacs`ns_select(nfds=<unavailable>, readfds=<unavailable>, writefds=<unavailable>, exceptfds=<unavailable>, timeout=<unavailable>, sigmask=<unavailable>) at nsterm.m:4861:3 [opt]
    frame #29: 0x000000010095e00d emacs`wait_reading_process_output(time_limit=<unavailable>, nsecs=<unavailable>, read_kbd=<unavailable>, do_display=<unavailable>, wait_for_cell=<unavailable>, wait_proc=0x0000000000000000, just_wait_proc=<unavailable>) at process.c:5609:18 [opt]
    frame #30: 0x0000000100612281 emacs`kbd_buffer_get_event(kbp=<unavailable>, used_mouse_menu=<unavailable>, end_time=<unavailable>) at keyboard.c:3874:4 [opt]
    frame #31: 0x00000001006110b7 emacs`read_event_from_main_queue(end_time=<unavailable>, local_getcjmp=<unavailable>, used_mouse_menu=<unavailable>) at keyboard.c:2160:7 [opt]
    frame #32: 0x00000001005ea5e3 emacs`read_decoded_event_from_main_queue(end_time=<unavailable>, local_getcjmp=<unavailable>, prev_event=<unavailable>, used_mouse_menu=<unavailable>) at keyboard.c:2224:11 [opt]
    frame #33: 0x00000001005e5b49 emacs`read_char(commandflag=1, map=(i = 0x0000629000019573), prev_event=(i = 0x0000000000000000), used_mouse_menu=<unavailable>, end_time=0x0000000000000000) at keyboard.c:2834:11 [opt]
    frame #34: 0x00000001005d8647 emacs`read_key_sequence(keybuf=<unavailable>, prompt=<unavailable>, dont_downcase_last=<unavailable>, can_return_switch_frame=<unavailable>, fix_current_buffer=<unavailable>, prevent_redisplay=<unavailable>) at keyboard.c:9552:12 [opt]
    frame #35: 0x00000001005d3fd1 emacs`command_loop_1 at keyboard.c:1354:15 [opt]
    frame #36: 0x0000000100863be5 emacs`internal_condition_case(bfun=(emacs`command_loop_1 at keyboard.c:1240), handlers=<unavailable>, hfun=(emacs`cmd_error at keyboard.c:923)) at eval.c:1359:25 [opt]
    frame #37: 0x000000010060fd68 emacs`command_loop_2(ignore=(i = 0x0000000000000000)) at keyboard.c:1095:11 [opt]
    frame #38: 0x00000001008629b6 emacs`internal_catch(tag=(i = 0x000000000000c990), func=(emacs`command_loop_2 at keyboard.c:1091), arg=(i = 0x0000000000000000)) at eval.c:1120:25 [opt]
    frame #39: 0x00000001005d14d0 emacs`command_loop at keyboard.c:1074:2 [opt]
    frame #40: 0x00000001005d11c9 emacs`recursive_edit_1 at keyboard.c:718:9 [opt]
    frame #41: 0x00000001005d189f emacs`Frecursive_edit at keyboard.c:790:3 [opt]
    frame #42: 0x00000001005ca4a6 emacs`main(argc=0, argv=<unavailable>) at emacs.c:2047:3 [opt]
    frame #43: 0x00007fff71b92cc9 libdyld.dylib`start + 1

In GNU Emacs 28.0.50 (build 89, x86_64-apple-darwin19.6.0, NS appkit-1894.60 Version 10.15.7 (Build 19H2))
 of 2020-10-31
Repository revision: 283b8d274bd54192b3876ce8bf2930a096391839
Repository branch: master
Windowing system distributor 'Apple', version 10.3.1894
System Description:  Mac OS X 10.15.7

Configured using:
 'configure --with-modules --without-xml2 --without-pop --with-mailutils
 --enable-gcc-warnings=warn-only --enable-checking=all
 --enable-check-lisp-object-type 'CFLAGS=-g3 -O1 -fsanitize=address
 -fsanitize=undefined -fno-omit-frame-pointer''

Configured features:
JPEG TIFF GIF PNG NOTIFY KQUEUE ACL GNUTLS ZLIB TOOLKIT_SCROLL_BARS NS
MODULES THREADS JSON PDUMPER LCMS2

Important settings:
  value of $LANG: de_DE.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc dired dired-loaddefs rfc822
mml easymenu mml-sec epa epg epg-config gnus-util rmail rmail-loaddefs
time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils phst skeleton derived edmacro kmacro pcase ffap
thingatpt url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util url-parse auth-source cl-seq eieio
eieio-core cl-macs eieio-loaddefs password-cache json map url-vars
mailcap rx gnutls puny dbus xml subr-x seq byte-opt gv bytecomp
byte-compile cconv compile text-property-search comint ansi-color ring
cl-loaddefs cl-lib tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process emacs)

Memory information:
((conses 16 70870 3425)
 (symbols 48 8580 1)
 (strings 32 23868 1428)
 (string-bytes 1 780264)
 (vectors 16 14940)
 (vector-slots 8 197741 15083)
 (floats 8 26 26)
 (intervals 56 212 0)
 (buffers 992 10))