Subject: bug#26323: 25.1; Closing frames (in fullscreen) under Mac OS cause immediate crash

From: Steve Perry <[email-masked]>
Date: Fri, 31 Mar 2017 20:13:54 +0100

Can also see this problem in 26.0.50.  FWIW f is non-NULL and the
contents look reasonable.  Backtrace etc.:

Process 73590 stopped
* thread #1: tid = 0x103905a, 0x00000001001bc3c1 Emacs`ns_clear_frame_area(f=0x0000000103a1cc18, x=0, y=0, width=595, height=564) + 65 at nsterm.m:2414, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
    frame #0: 0x00000001001bc3c1 Emacs`ns_clear_frame_area(f=0x0000000103a1cc18, x=0, y=0, width=595, height=564) + 65 at nsterm.m:2414 [opt]
   2411 {
   2412   NSRect r = NSMakeRect (x, y, width, height);
   2413   NSView *view = FRAME_NS_VIEW (f);
-> 2414   struct face *face = FRAME_DEFAULT_FACE (f);
   2415
   2416   if (!view || !face)
   2417     return;

(lldb) bt
* thread #1: tid = 0x103905a, 0x00000001001bc3c1 Emacs`ns_clear_frame_area(f=0x0000000103a1cc18, x=0, y=0, width=595, height=564) + 65 at nsterm.m:2414, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
  * frame #0: 0x00000001001bc3c1 Emacs`ns_clear_frame_area(f=0x0000000103a1cc18, x=0, y=0, width=595, height=564) + 65 at nsterm.m:2414 [opt]
    frame #1: 0x00000001001bc334 Emacs`-[EmacsView drawRect:](self=0x0000000111626c90, _cmd=<unavailable>, rect=(origin = (x = 0, y = 0), size = (width = 595, height = 564))) + 84 at nsterm.m:7497 [opt]
    frame #2: 0x00007fffa00a5af9 AppKit`-[NSView _drawRect:clip:] + 2276
    frame #3: 0x00007fffa00f5aab AppKit`-[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1753
    frame #4: 0x00007fffa00f5f16 AppKit`-[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2884
    frame #5: 0x00007fffa00f5f16 AppKit`-[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2884
    frame #6: 0x00007fffa00a3632 AppKit`-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 837
    frame #7: 0x00007fffa00a2e0f AppKit`-[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 334
    frame #8: 0x00007fffa00a1238 AppKit`-[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 2452
    frame #9: 0x00007fffa009cb25 AppKit`-[NSView displayIfNeeded] + 1748
    frame #10: 0x00007fffa009c437 AppKit`-[NSWindow displayIfNeeded] + 230
    frame #11: 0x00007fffa07faf3f AppKit`___NSWindowGetDisplayCycleObserver_block_invoke.6228 + 277
    frame #12: 0x00007fffa009bf15 AppKit`__37+[NSDisplayCycle currentDisplayCycle]_block_invoke + 454
    frame #13: 0x00007fffa814aa96 QuartzCore`CA::Transaction::run_commit_handlers(CATransactionPhase) + 46
    frame #14: 0x00007fffa8252800 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 160
    frame #15: 0x00007fffa8149631 QuartzCore`CA::Transaction::commit() + 475
    frame #16: 0x00007fffa8149f92 QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 108
    frame #17: 0x00007fffa243b397 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    frame #18: 0x00007fffa243b307 CoreFoundation`__CFRunLoopDoObservers + 391
    frame #19: 0x00007fffa241b996 CoreFoundation`CFRunLoopRunSpecific + 454
    frame #20: 0x00007fffa19a7a5c HIToolbox`RunCurrentEventLoopInMode + 240
    frame #21: 0x00007fffa19a7799 HIToolbox`ReceiveNextEventCommon + 184
    frame #22: 0x00007fffa19a76c6 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 71
    frame #23: 0x00007fff9ff4d5b4 AppKit`_DPSNextEvent + 1120
    frame #24: 0x00007fffa06c7d6b AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2789
    frame #25: 0x00000001001b2daf Emacs`ns_send_appdefined(value=-1) + 143 at nsterm.m:3890 [opt]
    frame #26: 0x00007fffa2431a6c CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    frame #27: 0x00007fffa243196b CoreFoundation`_CFXRegistrationPost + 427
    frame #28: 0x00007fffa24316d2 CoreFoundation`___CFXNotificationPost_block_invoke + 50
    frame #29: 0x00007fffa23eed63 CoreFoundation`-[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1827
    frame #30: 0x00007fffa23edd9c CoreFoundation`_CFXNotificationPost + 604
    frame #31: 0x00007fffa3e14a37 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 66
    frame #32: 0x00007fffa0019fc3 AppKit`-[NSWindow _setFrameCommon:display:stashSize:] + 3326
    frame #33: 0x00007fffa00192b7 AppKit`-[NSWindow _setFrame:display:allowImplicitAnimation:stashSize:] + 222
    frame #34: 0x00007fffa00191d2 AppKit`-[NSWindow setFrame:display:] + 67
    frame #35: 0x00000001001bdfba Emacs`-[EmacsWindow setFrame:display:](self=<unavailable>, _cmd=<unavailable>, windowFrame=(origin = (x = 543, y = 405), size = (width = 595, height = 564)), displayViews=<unavailable>) + 74 at nsterm.m:7948 [opt]
    frame #36: 0x00007fffa02624f4 AppKit`-[NSWindow _didExitFullScreen:] + 226
    frame #37: 0x00007fffa099073f AppKit`__123-[_NSWindowFullScreenTransition _performExitFullScreenModeForWindow:windowController:options:customWindows:doKitAnimation:]_block_invoke_2 + 390
    frame #38: 0x00007fffa09904c5 AppKit`__123-[_NSWindowFullScreenTransition _performExitFullScreenModeForWindow:windowController:options:customWindows:doKitAnimation:]_block_invoke + 1191
    frame #39: 0x00007fffa098ffbf AppKit`-[_NSWindowFullScreenTransition _performExitFullScreenModeForWindow:windowController:options:customWindows:doKitAnimation:] + 1616
    frame #40: 0x00007fffa0991355 AppKit`-[_NSWindowFullScreenTransition exitFullScreenTransitionForWindow:options:] + 895
    frame #41: 0x00007fffa0363776 AppKit`-[NSWindow(NSWindowTabbing) _doTabbedWindowCleanupForOrderOut] + 228
    frame #42: 0x00007fffa01e44cd AppKit`__18-[NSWindow _close]_block_invoke + 82
    frame #43: 0x00007fffa01e442c AppKit`-[NSWindow _close] + 365
    frame #44: 0x00000001001b1394 Emacs`x_free_frame_resources(f=0x0000000103a1cc18) + 292 at nsterm.m:1656 [opt]
    frame #45: 0x00000001001b13d6 Emacs`x_destroy_window(f=0x0000000103a1cc18) + 22 at nsterm.m:1672 [opt]
    frame #46: 0x000000010001046c Emacs`delete_frame(frame=<unavailable>, force=<unavailable>) + 1260 at frame.c:1718 [opt]
    frame #47: 0x000000010013f168 Emacs`funcall_subr(subr=0x0000000100228e20, numargs=0, args=<unavailable>) + 248 at eval.c:2820 [opt]
    frame #48: 0x000000010013e75f Emacs`Ffuncall(nargs=<unavailable>, args=<unavailable>) + 735 at eval.c:2743 [opt]
    frame #49: 0x0000000100137ff6 Emacs`Ffuncall_interactively(nargs=<unavailable>, args=<unavailable>) + 70 at callint.c:252 [opt]
    frame #50: 0x000000010013e75f Emacs`Ffuncall(nargs=<unavailable>, args=<unavailable>) + 735 at eval.c:2743 [opt]
    frame #51: 0x00000001001395dd Emacs`Fcall_interactively(function=<unavailable>, record_flag=0, keys=<unavailable>) + 5581 at callint.c:843 [opt]
    frame #52: 0x000000010013f17c Emacs`funcall_subr(subr=0x000000010058c880, numargs=3, args=<unavailable>) + 268 at eval.c:2823 [opt]
    frame #53: 0x000000010013e75f Emacs`Ffuncall(nargs=<unavailable>, args=<unavailable>) + 735 at eval.c:2743 [opt]
    frame #54: 0x000000010017ae3a Emacs`exec_byte_code(bytestr=<unavailable>, vector=<unavailable>, maxdepth=<unavailable>, args_template=4102, nargs=<unavailable>, args=<unavailable>) + 1738 at bytecode.c:641 [opt]
    frame #55: 0x000000010013e700 Emacs`Ffuncall(nargs=<unavailable>, args=<unavailable>) + 640 at eval.c:2745 [opt]
    frame #56: 0x000000010013ee3d Emacs`call1(fn=<unavailable>, arg1=<unavailable>) + 45 at eval.c:2605 [opt]
    frame #57: 0x00000001000bfb17 Emacs`command_loop_1 + 1895 at keyboard.c:1484 [opt]
    frame #58: 0x000000010013cf67 Emacs`internal_condition_case(bfun=(Emacs`command_loop_1 at keyboard.c:1261), handlers=<unavailable>, hfun=(Emacs`cmd_error at keyboard.c:940)) + 87 at eval.c:1324 [opt]
    frame #59: 0x00000001000ce970 Emacs`command_loop_2(ignore=<unavailable>) + 48 at keyboard.c:1112 [opt]
    frame #60: 0x000000010013c82e Emacs`internal_catch(tag=<unavailable>, func=(Emacs`command_loop_2 at keyboard.c:1108), arg=0) + 78 at eval.c:1091 [opt]
    frame #61: 0x00000001000beaae Emacs`command_loop + 158 at keyboard.c:1091 [opt]
    frame #62: 0x00000001000be9bf Emacs`recursive_edit_1 + 111 at keyboard.c:697 [opt]
    frame #63: 0x00000001000bebf3 Emacs`Frecursive_edit + 227 at keyboard.c:768 [opt]
    frame #64: 0x00000001000bd7d8 Emacs`main(argc=0, argv=<unavailable>) + 6072 at emacs.c:1683 [opt]
    frame #65: 0x00007fffb7973255 libdyld.dylib`start + 1