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: Tue, 25 Jul 2023 17:16:17 +0100 Message-ID: References: <87bkgjatup.fsf@eshelyaron.com> <87r0pdc9ej.fsf@eshelyaron.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9231"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 63495@debbugs.gnu.org, obriendavid1@gmail.com, me@eshelyaron.com To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 25 18:17:28 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 1qOKj1-0002Am-JK for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 25 Jul 2023 18:17:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOKie-00089f-4M; Tue, 25 Jul 2023 12:17:04 -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 1qOKic-00089A-Jz for bug-gnu-emacs@gnu.org; Tue, 25 Jul 2023 12:17:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOKic-0002Lx-Bn for bug-gnu-emacs@gnu.org; Tue, 25 Jul 2023 12:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qOKib-0002co-V6 for bug-gnu-emacs@gnu.org; Tue, 25 Jul 2023 12:17: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: Tue, 25 Jul 2023 16:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63495 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: "Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors" , obriendavid1@gmail.com, Eshel Yaron , 63495@debbugs.gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169030180110041 (code B ref -1); Tue, 25 Jul 2023 16:17:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Jul 2023 16:16:41 +0000 Original-Received: from localhost ([127.0.0.1]:46791 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qOKiH-0002bt-2c for submit@debbugs.gnu.org; Tue, 25 Jul 2023 12:16:41 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:42776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qOKiD-0002bQ-9g for submit@debbugs.gnu.org; Tue, 25 Jul 2023 12:16:38 -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 1qOKi7-0007ws-JO for bug-gnu-emacs@gnu.org; Tue, 25 Jul 2023 12:16:31 -0400 Original-Received: from dane.soverin.net ([185.233.34.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOKi4-0002I4-Uy for bug-gnu-emacs@gnu.org; Tue, 25 Jul 2023 12:16:31 -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) server-digest SHA256) (No client certificate requested) by dane.soverin.net (Postfix) with ESMTPS id 4R9MbW0JdHz10gh; Tue, 25 Jul 2023 16:16:23 +0000 (UTC) Original-Received: from smtp.soverin.net (smtp.soverin.net [10.10.4.99]) by soverin.net (Postfix) with ESMTPSA id 4R9MbV2W4XzGL; Tue, 25 Jul 2023 16:16:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin; t=1690301782; bh=5N8gqcSPCOr0W/mh7NYq+uerQC2Y/XvLk+eASCYp/NA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c8TB3YaPfnYb5Lg01n+jQwhphK+DUxl2bosvFpWj4D5WjM5hWrB45aJrfUEHS8+Af FPL+LDMUpybBfz6niTm+l4WyDdsgs5L+jly4FzHbZSbyV7h6cT12Vt+Fl9K8IzeflD Ps6w3X7KQaZkTfma/9i4YuUSrvw2efw9wernBRbjuUp9SqTgg3hwgR5J2q0zvLVrPA w7PTlOdXTB4UWx99bPZX1clQ85HvRIXO3fpm+YNFVsXzJLcIdhqE1jJNa/DEtBdUov i9JBjEHVhrOlnWMp8zuwtIXnQ6X6916W//G1mXHrDE+CtHorYDgbBpun/ne2s9+9Z9 cEkOe3VcTQ3Bg== Original-Received: from alan by faroe.holly.idiocy.org with local (Exim 4.96) (envelope-from ) id 1qOKhu-000Hfh-28; Tue, 25 Jul 2023 17:16:18 +0100 X-Soverin-Authenticated: true Mail-Followup-To: Alan Third , Daniel =?UTF-8?Q?Mart=C3=ADn?= , "Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors" , Eshel Yaron , obriendavid1@gmail.com, 63495@debbugs.gnu.org Content-Disposition: inline In-Reply-To: X-CMAE-Score: 0 X-CMAE-Analysis: v=2.4 cv=Mfmq+bzf c=1 sm=1 tr=0 ts=64bff556 a=8nJEP1OIZ-IA:10 a=ws7JD89P4LkA:10 a=sSdNXfNkPd9oIJn9uowA:9 a=7Zwj6sZBwVKJAoWSPKxL6X1jA+E=:19 a=wPNLvfGTeEIA:10 X-Cloudmark-Reporter: XwCdxO2Qeu+pd3DeZ7wndH9OM0E= Received-SPF: pass client-ip=185.233.34.25; envelope-from=alan@idiocy.org; helo=dane.soverin.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:266078 Archived-At: On Thu, Jul 13, 2023 at 10:47:35AM +0200, Daniel Martín wrote: > One fundamental problem I see with the current logic (or maybe I'm > misunderstanding something) is that, menuNeedsUpdate: is called for both > the menubar and for context menus. However, the ns_update_menubar > routine does not even use the NSMenu that AppKit passed to > menuNeedsUpdate:, it always does this: > > id menu = [NSApp mainMenu]; > > This means that the menu variable will always be the menubar. The code > in ns_update_menubar is only prepared to handle menubar updates, but as > this function updates menu_items, a data structure that is used later by > the context menu in find_and_return_menu_selection, Emacs crashes > because of inconsistencies. > > Is there any reason we need to do something for context menus in > menuNeedsUpdate:? Alan said that context menus are completely built in > advance (as opposed to the menubar, which is partially built), so I > propose the following patch (which does seem to fix the crash for me and > doesn't cause regressions with the menubar): > > diff --git a/src/nsmenu.m b/src/nsmenu.m > index 2c1f575bdf2..ca367d1abd1 100644 > --- a/src/nsmenu.m > +++ b/src/nsmenu.m > @@ -477,6 +477,16 @@ - (instancetype)initWithTitle: (NSString *)title > call to ns_update_menubar. */ > - (void)menuNeedsUpdate: (NSMenu *)menu > { > + > + /* The context menu is built and then displayed, as opposed to the > + top-menu, which is partially built and then updated and filled in > + when it's time to display it. Therefore, we don't call > + ns_update_menubar if a context menu is active. */ > + if (context_menu_value != 0) > + { > + return; > + } > + > #ifdef NS_IMPL_GNUSTEP > static int inside = 0; > #endif If it hasn't already, this should probably be pushed into the emacs-29 branch, unless someone's noticed a problem with it, as I understand the first(?) rc has already been released. This fixes a crash. Eli/Lars? Is it too late? -- Alan Third