Opened 12 months ago

Last modified 7 months ago

#68706 assigned defect

emacs-mac-app: Locks Up When Raising Context Menu

Reported by: kickingvegas (Charles Choi) Owned by: amake (Aaron Madlon-Kay)
Priority: Normal Milestone:
Component: ports Version: 2.8.1
Keywords: Cc: cooljeanius (Eric Gallager)
Port: emacs-mac-app

Description (last modified by ryandesign (Ryan Carsten Schmidt))

Title

Emacs Mac App Locks Up When Raising Context Menu

Description

I am able to intermittently lock up the Emacs Mac App when using context-menu mode (described in Menu Mouse Clicks (GNU Emacs Manual)).

Environment

OS: 14.1.1 (23B81) MacPorts: 2.8.1 HW: Apple M1 Pro

Steps to Reproduce

  1. Launch Emacs Mac App from command line using -Q argument to bypass any user configuration.
  2. Turn on context menu mode (M-x context-menu-mode)
  3. Repeatedly invoke/raise the context menu by right-mouse button (button 3) clicking on the current buffer and moving the mouse cursor over a menu item and pulling it away to not invoke a menu command.

Expected Result

No action should be taken by Emacs as no command from the context menu is selected.

Actual Result

Emacs Mac App locks up. The following message was emitted on the console:

┏━ cchoi@bingsu:/Applications/MacPorts/EmacsMac.app/Contents/MacOS
┗━━ $ ./Emacs.sh  -Q
2023-11-14 20:24:24.764 Emacs[36346:246906] TSM AdjustCapsLockLEDForKeyTransitionHandling - _ISSetPhysicalKeyboardCapsLockLED Inhibit
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_NSServiceEntry getBytes:length:]: unrecognized selector sent to instance 0x600001e60700'
*** First throw call stack:
(
        0   CoreFoundation                      0x00000001869ce800 __exceptionPreprocess + 176
        1   libobjc.A.dylib                     0x00000001864c5eb4 objc_exception_throw + 60
        2   CoreFoundation                      0x0000000186a803bc -[NSObject(NSObject) __retain_OA] + 0
        3   CoreFoundation                      0x0000000186938a84 ___forwarding___ + 1572
        4   CoreFoundation                      0x00000001869383a0 _CF_forwarding_prep_0 + 96
        5   Emacs                               0x00000001046e1c8c -[EmacsController(Menu) menu:willHighlightItem:] + 76
        6   AppKit                              0x000000018a3da664 -[NSMenu _informDelegateOfHighlightedItem:] + 140
        7   AppKit                              0x000000018a9310a8 -[NSCocoaMenuImpl _addHighlightForView:] + 356
        8   AppKit                              0x000000018a930cf8 __60-[NSCocoaMenuImpl _highlightMenuItemView:shouldOpenSubmenu:]_block_invoke + 224
        9   AppKit                              0x000000018a930958 -[NSCocoaMenuImpl _highlightMenuItemView:shouldOpenSubmenu:] + 300
        10  AppKit                              0x000000018a92fedc -[NSCocoaMenuImpl _routeEventIfNeeded:toSubview:] + 564
        11  AppKit                              0x000000018a92fa5c -[NSCocoaMenuImpl handleMouseEvent:] + 232
        12  AppKit                              0x000000018a7122e0 -[NSContextMenuImpl handleMovedDraggedEvent:] + 168
        13  AppKit                              0x000000018a758720 -[NSMenuTrackingSession _sendMouseMovedDragged:] + 96
        14  AppKit                              0x000000018a757cf8 -[NSMenuTrackingSession _mouseMovedDraggedEventHandler:] + 1956
        15  AppKit                              0x000000018a7558d4 -[NSMenuTrackingSession handleEvent:] + 180
        16  AppKit                              0x000000018a75504c -[NSMenuTrackingSession startRunningMenuEventLoop:] + 420
        17  AppKit                              0x000000018ae8685c -[NSContextMenuTrackingSession startMonitoringEventsInMode:] + 76
        18  AppKit                              0x000000018a70e508 +[NSContextMenuImpl presentPopup:fromView:withContext:animated:] + 640
        19  AppKit                              0x000000018a933fc4 _NSPopUpMenu + 1988
        20  AppKit                              0x000000018a93857c -[NSCocoaMenuImpl _popUpContextMenu:withEvent:forView:withFont:] + 304
        21  AppKit                              0x000000018a4579d8 -[NSMenu _popUpContextMenu:withEvent:forView:withFont:] + 188
        22  Emacs                               0x00000001046e2420 -[EmacsFrameController(Menu) popUpMenu:atLocationInEmacsView:] + 232
        23  Emacs                               0x00000001046e2e4c __create_and_show_popup_menu_block_invoke_2 + 44
        24  Emacs                               0x00000001046f11c4 __mac_within_gui_allowing_inner_lisp_block_invoke + 28
        25  Emacs                               0x00000001046effa4 mac_gui_loop + 88
        26  Emacs                               0x00000001047097ec main.cold.1 + 16
        27  Emacs                               0x00000001046efc98 main + 616
        28  dyld                                0x00000001865010e0 start + 2360
)
libc++abi: terminating due to uncaught exception of type NSException
Killed: 9

At this point, force quitting the app is the only available option, opening the risk to loss of state that is not persisted.

Attachments (1)

emacs-mac-app-context-menu-bug.png (177.1 KB) - added by kickingvegas (Charles Choi) 12 months ago.
Screenshot of context menu

Download all attachments as: .zip

Change History (10)

comment:1 Changed 12 months ago by kickingvegas (Charles Choi)

Keywords: Emacs added
Port: emacs-mac-app added
Version: 2.8.1

Changed 12 months ago by kickingvegas (Charles Choi)

Screenshot of context menu

comment:2 Changed 12 months ago by kickingvegas (Charles Choi)

Was able to more consistently reproduce the lock up. Apparently hovering over the macOS generated menu items at the bottom of the context menu a couple of times (< 5) will lock up the app. A screenshot of the context menu is attached.

comment:3 Changed 12 months ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)
Keywords: Emacs removed
Owner: set to amake
Status: newassigned
Summary: Emacs Mac App Locks Up When Raising Context Menuemacs-mac-app: Locks Up When Raising Context Menu

You could test with emacs-mac-app-devel (a presumably newer development version) to see if the issue remains. If it does, you could report it to the developers.

comment:4 Changed 12 months ago by kickingvegas (Charles Choi)

@ryandesign - apparently emacs-mac-app-devel is at the same version (20230805) as emacs-mac-app.

Will try to report it with mituharu+bug-gnu-emacs-mac@…

comment:5 Changed 12 months ago by kickingvegas (Charles Choi)

Got response back from Mitsuharu Yamamoto, fix commit here. https://bitbucket.org/mituharu/emacs-mac/commits/f07ef590bae37bfbe9fc13767288bd9614587335

Look forward to when this gets pushed out to emacs-mac-app.

Last edited 12 months ago by kickingvegas (Charles Choi) (previous) (diff)

comment:6 Changed 12 months ago by Aaron Madlon-Kay <aaron@…>

In 5eef3cec8e920f89766080149f56f7c630b97649/macports-ports (master):

emacs-mac-app-devel: update to 2023-11-16

See #68706

comment:7 Changed 12 months ago by amake (Aaron Madlon-Kay)

This won't make it to emacs-mac-app until there's a new release, but you can use emacs-mac-app-devel.

comment:8 Changed 9 months ago by kickingvegas (Charles Choi)

Waiting with baited breath for 29.2.

comment:9 Changed 7 months ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added
Note: See TracTickets for help on using tickets.