From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#63495: 28.2; menu crashes on macos Date: Wed, 12 Jul 2023 20:37:16 +0100 Message-ID: References: <87bkgjatup.fsf@eshelyaron.com> <87r0pdc9ej.fsf@eshelyaron.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1317"; mail-complaints-to="usenet@ciao.gmane.io" Cc: obriendavid1@gmail.com, 63495@debbugs.gnu.org, Daniel =?UTF-8?Q?Mart=C3=ADn?= To: Eshel Yaron Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 12 21:38:21 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qJffJ-00005W-2b for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 Jul 2023 21:38:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJff1-0005AM-Ty; Wed, 12 Jul 2023 15:38:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJff0-0004yc-84 for bug-gnu-emacs@gnu.org; Wed, 12 Jul 2023 15:38:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qJfez-0005fO-Vq for bug-gnu-emacs@gnu.org; Wed, 12 Jul 2023 15:38:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qJfez-0003gb-RK for bug-gnu-emacs@gnu.org; Wed, 12 Jul 2023 15:38:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 12 Jul 2023 19:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63495 X-GNU-PR-Package: emacs Original-Received: via spool by 63495-submit@debbugs.gnu.org id=B63495.168919064714098 (code B ref 63495); Wed, 12 Jul 2023 19:38:01 +0000 Original-Received: (at 63495) by debbugs.gnu.org; 12 Jul 2023 19:37:27 +0000 Original-Received: from localhost ([127.0.0.1]:52976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJfeR-0003fJ-78 for submit@debbugs.gnu.org; Wed, 12 Jul 2023 15:37:27 -0400 Original-Received: from dane.soverin.net ([185.233.34.157]:33591) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJfeO-0003ex-2u for 63495@debbugs.gnu.org; Wed, 12 Jul 2023 15:37:26 -0400 Original-Received: from smtp.soverin.net (c04smtp-lb01.int.sover.in [10.10.4.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by dane.soverin.net (Postfix) with ESMTPS id 4R1SgK4w8cz10XB; Wed, 12 Jul 2023 19:37:17 +0000 (UTC) Original-Received: from smtp.soverin.net (smtp.soverin.net [10.10.4.100]) by soverin.net (Postfix) with ESMTPSA id 4R1SgJ6xTnzHK; Wed, 12 Jul 2023 19:37:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin; t=1689190637; bh=K0AfOGjOe+wF6+fFPX7WBCJLzKVCdstfA1etP9q9AJk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=efHkhwXuloHxDPF78hh+ITYaY5XTrhQ57FkJpn40bscqCCH7Js7QIJU0zr6oDAIJ5 sB+7cOgou3klusdAAs1mjk3vhiKpXYj7byglsw3bawusdjZ7orYC6OGEgnp714rkVw O7N2P8OpePzRU9RW3oOKQww7RhS/qnwYV3oc8m69hBgWlXj2cK1iSJpiO6oxwnF3GL GRKRuX0xdeJeDjyd+vFFShetes897mZwcZ96mqDHNx5fdnMwNs8TEOe9nwK0nhqeoe eORjNMgKi410U+Wu/0bwmOf+e+XBNuTtdkV95QcLhrJPUwM4nYsgvMpuKpgyBMaxmO s/38gaIKGvXQQ== Original-Received: from alan by faroe.holly.idiocy.org with local (Exim 4.96) (envelope-from ) id 1qJfeG-00055E-0t; Wed, 12 Jul 2023 20:37:16 +0100 X-Soverin-Authenticated: true Mail-Followup-To: Alan Third , Eshel Yaron , Daniel =?UTF-8?Q?Mart=C3=ADn?= , 63495@debbugs.gnu.org, obriendavid1@gmail.com Content-Disposition: inline In-Reply-To: <87r0pdc9ej.fsf@eshelyaron.com> X-CMAE-Score: 0 X-CMAE-Analysis: v=2.4 cv=JPD98eGb c=1 sm=1 tr=0 ts=64af00ed a=kj9zAlcOel0A:10 a=ws7JD89P4LkA:10 a=hIj89exaAAAA:8 a=240M0dV7JxTxerZIMvwA:9 a=7Zwj6sZBwVKJAoWSPKxL6X1jA+E=:19 a=CjuIK1q_8ugA:10 a=lS9wXHQM5UdnNJ4u63Ry:22 X-Cloudmark-Reporter: Sou+UQm6pxRFzGDtu8lWqa3ULXE= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:264982 Archived-At: On Wed, Jul 12, 2023 at 08:44:04PM +0300, Eshel Yaron wrote: > Alan Third writes: > > >> > There's nothing obvious in that function that would be doing that, > >> > so it would be good if we could get a backtrace from a debugger > >> > showing the exact line that's causing the problem and, if possible, > >> > which variable has the value 3. > >> > >> There's this backtrace that I've posted in Bug#62402, HTH: > >> > >> > * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x3) > >> > * frame #0: 0x00000001000aebad emacs`AREF(array=0x0000000000000000, idx=0) at lisp.h:1947:10 > >> > frame #1: 0x00000001000af660 emacs`find_and_return_menu_selection(f=0x00000001100dee30, keymaps=true, client_data=0x000000011089b888) at menu.c:985:11 > >> > frame #2: 0x0000000100380f2b emacs`-[EmacsMenu runMenuAt:forFrame:keymaps:](self=0x00006000017007c0, _cmd="runMenuAt:forFrame:keymaps:", p=(x = 2, y = 506), f=0x00000001100dee30, keymaps=true) at nsmenu.m:767:9 > >> > frame #3: 0x0000000100381f00 emacs`ns_menu_show(f=0x00000001100dee30, x=2, y=2, menuflags=1, title=0x0000000000000000, error=0x00007ff7bfefce80) at nsmenu.m:1067:9 > >> > frame #4: 0x00000001000b1203 emacs`x_popup_menu_1(position=0x000000011804dcb3, menu=0x000000011804e003) at menu.c:1410:17 > >> > frame #5: 0x00000001000b15a2 emacs`Fx_popup_menu(position=0x000000011804dcb3, menu=0x000000011804e003) at menu.c:1474:10 > >> > frame #6: 0x0000000100247c58 emacs`eval_sub(form=0x000000011804dd23) at eval.c:2503:15 > >> > ... > >> > > >> > It seems that `find_and_return_menu_selection` in menu.c tries to > >> > access the global variable `menu_items` before it's initialized. I'm > >> > not sure when or where it should be initialized though :( > > > > No, sorry, I need the output from a debugger. That should give the > > exact line where the failure happens. > > I'm not sure I understand, this *is* the output from a debugger. I ran > Emacs under lldb and got the above backtrace when it crashed. It also > includes the exact line number(s). What am I missing? Sorry, I misunderstood what I was looking at. Can you please try this: modified src/nsmenu.m @@ -746,6 +746,8 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f NSEvent *e, *event; long retVal; + needsUpdate = NO; + /* p = [view convertPoint:p fromView: nil]; */ p.y = NSHeight ([view frame]) - p.y; e = [[view window] currentEvent]; At a guess, when the menu opens the first thing AppKit does is check if it needs updated, and since a new menu starts with needsUpdate=YES, it goes ahead and tries to do it, which overwrites some important variables from the original "build" of the menu. The context menu is built and then displayed, as opposed to the top-menu that is partially built, then when it's to be displayed is updated and filled in. -- Alan Third