Subject: bug#76691: `display-monitor-attributes-list` not working properly on macOS

From: Robert Pluim <[email-masked]>
Date: Wed, 05 Mar 2025 09:53:04 +0100

>>>>> On Tue, 4 Mar 2025 12:34:11 -0500, Ship Mints <[email-masked]> said:

    >> Yes, emacs crashes when I run `make-frame-on-monitor' :-)
    >> 

    Ship> Does Emacs work when you run make-frame-on-current-monitor starting from a
    Ship> selected frame on a secondary monitor?  make-frame-on-current-monitor does
    Ship> not depend on monitor names.  It would give me a hint where to look.  Even
    Ship> make-frame-on-monitor uses a monitor name only to get the geometry at which
    Ship> to place the new frame so if -current-monitor works but not named, it'll be
    Ship> interesting.

`make-frame-on-current-monitor' works fine. And of course now I canʼt
reproduce the crash after recompiling with "-O0 -g3", although today
Iʼm using a different monitor than yesterday. I can try the original
one again tomorrow. I do have a backtrace, but unfortunately donʼt
have that lldb session anymore.

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00000001854e3720 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x000000018551bf70 libsystem_pthread.dylib`pthread_kill + 288
    frame #2: 0x0000000185428908 libsystem_c.dylib`abort + 128
    frame #3: 0x0000000185331e38 libsystem_malloc.dylib`malloc_vreport + 896
    frame #4: 0x000000018535a458 libsystem_malloc.dylib`malloc_zone_error + 100
    frame #5: 0x0000000185349774 libsystem_malloc.dylib`nanov2_guard_corruption_detected + 44
    frame #6: 0x0000000185349734 libsystem_malloc.dylib`nanov2_allocate_outlined + 460
    frame #7: 0x0000000185348468 libsystem_malloc.dylib`nanov2_calloc_type + 568
    frame #8: 0x000000018514ba44 libobjc.A.dylib`class_createInstance + 72
    frame #9: 0x000000018558b5a8 CoreFoundation`__CFAllocateObject + 20
    frame #10: 0x000000018558b558 CoreFoundation`__NSSingleObjectArrayI_new + 48
    frame #11: 0x00000001855adc78 CoreFoundation`-[NSArray initWithArray:range:copyItems:] + 368
    frame #12: 0x0000000185605118 CoreFoundation`-[NSMutableArray sortedArrayFromRange:options:usingComparator:] + 64
    frame #13: 0x000000018924efe0 AppKit`_distributeSpaceToItems + 872
    frame #14: 0x00000001899a0664 AppKit`-[NSBarLayout _calculateLayoutOfItems:inRect:sharesLeadingEdge:sharesTrailingEdge:] + 1260
    frame #15: 0x00000001899a013c AppKit`-[NSBarLayout _enumerateSectionsOfItems:usingBlock:] + 208
    frame #16: 0x000000018999f900 AppKit`-[NSBarLayout _updateAttributesOfItems:inRect:] + 352
    frame #17: 0x000000018999f5e4 AppKit`-[NSBarLayout layoutAttributesOfVisibleItems] + 312
    frame #18: 0x0000000189243c18 AppKit`-[NSToolbarView _layoutDirtyItemViewersAndTileToolbar] + 2192
    frame #19: 0x000000018925e360 AppKit`-[NSToolbarView layout] + 80
    frame #20: 0x0000000189c67c7c AppKit`___NSViewLayout_block_invoke + 632
    frame #21: 0x00000001891bc4d8 AppKit`NSPerformVisuallyAtomicChange + 108
    frame #22: 0x00000001891c0dac AppKit`_NSViewLayout + 96
    frame #23: 0x0000000189c5df20 AppKit`__36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 372
    frame #24: 0x00000001891bc4d8 AppKit`NSPerformVisuallyAtomicChange + 108
    frame #25: 0x00000001891c0d40 AppKit`-[NSView _layoutSubtreeWithOldSize:] + 100
    frame #26: 0x0000000189c5e064 AppKit`__36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 696
    frame #27: 0x00000001891bc4d8 AppKit`NSPerformVisuallyAtomicChange + 108
    frame #28: 0x00000001891c0d40 AppKit`-[NSView _layoutSubtreeWithOldSize:] + 100
    frame #29: 0x0000000189c5e064 AppKit`__36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 696
    frame #30: 0x00000001891bc4d8 AppKit`NSPerformVisuallyAtomicChange + 108
    frame #31: 0x00000001891c0d40 AppKit`-[NSView _layoutSubtreeWithOldSize:] + 100
    frame #32: 0x0000000189c5e064 AppKit`__36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 696
    frame #33: 0x00000001891bc4d8 AppKit`NSPerformVisuallyAtomicChange + 108
    frame #34: 0x00000001891c0d40 AppKit`-[NSView _layoutSubtreeWithOldSize:] + 100
    frame #35: 0x0000000189c5eb00 AppKit`__56-[NSView _layoutSubtreeIfNeededAndAllowTemporaryEngine:]_block_invoke + 908
    frame #36: 0x00000001891bc4d8 AppKit`NSPerformVisuallyAtomicChange + 108
    frame #37: 0x00000001891c0918 AppKit`-[NSView _layoutSubtreeIfNeededAndAllowTemporaryEngine:] + 100
    frame #38: 0x00000001891bc4d8 AppKit`NSPerformVisuallyAtomicChange + 108
    frame #39: 0x00000001891c08a8 AppKit`-[NSView layoutSubtreeIfNeeded] + 96
    frame #40: 0x0000000189f463bc AppKit`-[NSWindow(NSConstraintBasedLayoutInternal) _layoutViewTree] + 104
    frame #41: 0x00000001891be588 AppKit`-[NSWindow _oldPlaceWindow:fromServer:] + 540
    frame #42: 0x00000001891bda34 AppKit`-[NSWindow _setFrameCommon:display:fromServer:] + 2032
    frame #43: 0x0000000100207ab0 emacs`-[EmacsWindow setFrame:display:](self=<unavailable>, _cmd=<unavailable>, windowFrame=<unavailable>, displayViews=<unavailable>) at nsterm.m:9899:3 [opt]
    frame #44: 0x0000000100207ae4 emacs`-[EmacsWindow setFrame:display:animate:](self=<unavailable>, _cmd=<unavailable>, windowFrame=<unavailable>, displayViews=<unavailable>, performAnimation=<unavailable>) at nsterm.m:9910:3 [opt]
    frame #45: 0x0000000189259778 AppKit`-[NSThemeFrame _growWindowReshapeContentAndToolbarView:withOldToolbarFrameSize:animate:] + 976
    frame #46: 0x00000001892591fc AppKit`-[NSThemeFrame _reshapeContentAndToolbarView:withOldToolbarFrameSize:resizeWindow:animate:] + 200
    frame #47: 0x000000018924031c AppKit`-[NSThemeFrame _showHideToolbar:resizeWindow:animate:] + 156
    frame #48: 0x0000000189232448 AppKit`-[NSWindow _showToolbar:animate:] + 140
    frame #49: 0x000000018923234c AppKit`-[NSToolbar _show:animate:] + 96
    frame #50: 0x00000001892322b4 AppKit`-[NSToolbar _toggleShown:animate:] + 92
    frame #51: 0x000000018922ecd0 AppKit`-[NSWindow setToolbar:] + 384
    frame #52: 0x00000001002069a4 emacs`-[EmacsWindow createToolbar:](self=0x000000011de10030, _cmd=<unavailable>, f=0x000000012e106de8) at nsterm.m:9383:3 [opt]
    frame #53: 0x00000001002068b4 emacs`-[EmacsWindow initWithEmacsFrame:fullscreen:screen:](self=0x000000011de10030, _cmd=<unavailable>, f=0x000000012e106de8, fullscreen=<unavailable>, screen=<unavailable>) at nsterm.m:9350:7 [opt]
    frame #54: 0x00000001002039c0 emacs`-[EmacsView initFrameFromEmacs:](self=0x000000011de0fc50, _cmd=<unavailable>, f=0x000000012e106de8) at nsterm.m:8089:3 [opt]
    frame #55: 0x0000000100212f48 emacs`Fx_create_frame(parms=(struct Lisp_Cons *) $4 = 0x0000000120058560) at nsfns.m:1513:3 [opt]

Robert
--