From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#39977: 28.0.50; Unhelpful stack trace Date: Tue, 17 Mar 2020 18:31:18 +0100 Message-ID: <7a0b9999-6778-6235-fbc9-2a24b4e3bc53@gmx.at> References: <83zhcs80e5.fsf@gnu.org> <83imj88tpt.fsf@gnu.org> <550fbc22-09db-d30b-c194-8f26b5dca05f@gmx.at> <83wo7o6nxs.fsf@gnu.org> <60dd4ced-a2e5-ed17-0570-b7bdd2a557af@gmx.at> <83blozckn2.fsf@gnu.org> <01305dbc-c69b-baf9-f0bf-1e5b8c04d970@gmx.at> <83y2s2bswl.fsf@gnu.org> <3ac189d0-5d05-fdf9-0922-0c464b1b17c3@gmx.at> <83k13lbgux.fsf@gnu.org> <83d09cb9gz.fsf@gnu.org> <69a74f9e-079b-a771-0213-f60ed0bf5720@gmx.at> <83y2rzf08m.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------D1A4A937170B4EA6EB2BB62D" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="108741"; mail-complaints-to="usenet@ciao.gmane.io" Cc: enometh@meer.net, 39977@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 17 18:32:55 2020 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 1jEG5F-000S7A-Dd for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 Mar 2020 18:32:53 +0100 Original-Received: from localhost ([::1]:37570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEG5D-0005iS-RE for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 Mar 2020 13:32:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40953) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEG4S-0005hk-6t for bug-gnu-emacs@gnu.org; Tue, 17 Mar 2020 13:32:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEG4Q-0000It-Pq for bug-gnu-emacs@gnu.org; Tue, 17 Mar 2020 13:32:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33552) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEG4Q-0000H0-Li for bug-gnu-emacs@gnu.org; Tue, 17 Mar 2020 13:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jEG4Q-0000Vr-HW for bug-gnu-emacs@gnu.org; Tue, 17 Mar 2020 13:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Mar 2020 17:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39977 X-GNU-PR-Package: emacs Original-Received: via spool by 39977-submit@debbugs.gnu.org id=B39977.15844662941938 (code B ref 39977); Tue, 17 Mar 2020 17:32:02 +0000 Original-Received: (at 39977) by debbugs.gnu.org; 17 Mar 2020 17:31:34 +0000 Original-Received: from localhost ([127.0.0.1]:39525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jEG3x-0000VB-JH for submit@debbugs.gnu.org; Tue, 17 Mar 2020 13:31:33 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:56143) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jEG3v-0000Ux-AL for 39977@debbugs.gnu.org; Tue, 17 Mar 2020 13:31:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1584466280; bh=E6+C81LiFPq+yytggIeTbdGNn0GG5OYlbi+D5UsRV3I=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=GfE9VbJH5oXAmYlUH+/Y1WgM8L3yUFrSmfvWgcpGR49CWiHxouKd/Lgm1H8wk5xFM RC8Hzw5PhsCoS7H00AaXgA98t1/NjV09T0BJTn3QEaeP0b/G35VvBsercIavIJ/Qkb p+DmySC3CJGUVa0SSgXAibx+rEJXTwJ475IVEVIQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [192.168.1.101] ([212.95.5.16]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M26vL-1jGAnh12Kn-002b8C; Tue, 17 Mar 2020 18:31:20 +0100 In-Reply-To: <83y2rzf08m.fsf@gnu.org> Content-Language: en-US X-Provags-ID: V03:K1:pHJANxacxx4Cm6ltzDtm+T1RVtWa2j78GZ/uBzHvRIRn/tDbMNj oYGiJnzsnT2lsUU6roNRQcnhO/Hzf91VNi9RaH7M+xJvcNqDwqn+XIR22zl0JwDY+t5Rqha v5OKhW2rKIc7jljGNRYrhpXhyPe0VVU6++HNsH8lSInC8RlqDtoh8vbGxMRkJJJh6PWfjdb 1bLUSmL4+kztvv5iQrJ2w== X-UI-Out-Filterresults: notjunk:1;V03:K0:0hbxc1SKLlY=:Bp0EdcChyUHIiNqYDiDuUp XOPRQKz9EnVZRzaZiOTwmO600o/R2uqEryGtLjp2VN35ZWfeg5SFr7fXp5yF5PITdRYPZ54en Y3j+4cYmRaGI7p0J0Mn7MyFk1s2Av0mSWmnnncmv7r19jwgWfJsTj9Y6QKlrLIhNzFeCGP82Y hoV6LJcQHsrJaFKNmnvZWBOvq0cfhG/NIVKqzWQRCBXH8gDWA7i+0wGFqBRSBD8ud9PDvnZlN 669hZNEecOVhZuKKWKkfromdlvPG8KhTGfORDtCmeKG4zN4cvg7Vvyb6Ib9ZUi4+vBOifiitN uEgWTgZ+TiprqH0MASZal8DP9wDVSPmNApfqcFLcgkaDoG9PDdy5gEXMGtt+TSb1YjvZQR5Ly MW+PG9a1i0vt/LgalDxrdcFZBnX3RloZ5JgBjWqJe17sYHOtJbtIzHzqnnrYMOJJcGGY6ZVCz eeCXGlAjBOiVhiSA8ldvvNQfQhlhLxFh8Xd82AZTrtu/dQNMejg4YHT7vunc664yKdKNZTjY0 UcsOIamotAeGTJNg2j8v/6aaaHICmQBbmvKneOLM6CCoDCe+zJa2ulf2PKaXYSRrASkujRC7o mdyddZ+dYVMlTVs/tFqdRbv/a99Y+vy4C7B0BMKlDIEIDR+QOQPUZQPxQHhcLk36DSKS37Yye RLGL4imlSUMI2SlJaiegl6Gchx2Fq4Lt5Lb9uFjAgHpXmHWpHkx8oCjDmXJpPOuHmdX3P0eCG E5Ie9EHuIHwyQujz+W9usKWidUr+eFNk5Wct4GsA9Cs9iryx0jqC/Ey6FbZeNkj1hLJTqFJz X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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" Xref: news.gmane.io gmane.emacs.bugs:177462 Archived-At: This is a multi-part message in MIME format. --------------D1A4A937170B4EA6EB2BB62D Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit > You are proposing that we find all the places where SELECTED_FRAME is > used and fix them one by one? I thought it could be better to fix > them all at once as part of SELECTED_FRAME. We are still miscommunicating. I only want to fix the parts that restore selected_frame so to make sure that they never set it to a dead frame. See the attached selected_frame.diff. martin --------------D1A4A937170B4EA6EB2BB62D Content-Type: text/x-patch; name="selected_frame.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="selected_frame.diff" diff --git a/src/frame.c b/src/frame.c index 88d6f22fc0..ef42f230ef 100644 =2D-- a/src/frame.c +++ b/src/frame.c @@ -1466,6 +1466,11 @@ do_switch_frame (Lisp_Object frame, int track, int = for_deletion, Lisp_Object nor tty->top_frame =3D frame; } + if (!FRAME_LIVE_P (f)) + /* Return nil if for some reason FRAME has become dead now + (Bug#39977). */ + return Qnil; + selected_frame =3D frame; if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame))) last_nonminibuf_frame =3D XFRAME (selected_frame); @@ -2009,8 +2014,6 @@ delete_frame (Lisp_Object frame, Lisp_Object force) error ("Attempt to delete the only frame"); } - /* At this point, we are committed to deleting the frame. - There is no more chance for errors to prevent it. */ minibuffer_selected =3D EQ (minibuf_window, selected_window); sf =3D SELECTED_FRAME (); /* Don't let the frame remain selected. */ @@ -2066,10 +2069,17 @@ delete_frame (Lisp_Object frame, Lisp_Object force= ) Fraise_frame (frame1); #endif - do_switch_frame (frame1, 0, 1, Qnil); + if (!EQ (do_switch_frame (frame1, 0, 1, Qnil), frame1)) + /* Error out if for some reason FRAME1 was not live + (Bug#39977). */ + error ("No frame to switch to found"); + sf =3D SELECTED_FRAME (); } + /* At this point, we are committed to deleting the frame. + There is no more chance for errors to prevent it. */ + /* Don't allow minibuf_window to remain on a deleted frame. */ check_minibuf_window (frame, minibuffer_selected); diff --git a/src/xdisp.c b/src/xdisp.c index 3a8b5e3f1d..e573c7cf88 100644 =2D-- a/src/xdisp.c +++ b/src/xdisp.c @@ -12608,6 +12608,16 @@ fast_set_selected_frame (Lisp_Object frame) } } +static void +fast_set_selected_frame_if_live (Lisp_Object frame) +{ + if (!EQ (selected_frame, frame) && FRAME_LIVE_P (XFRAME (frame))) + { + selected_frame =3D frame; + selected_window =3D XFRAME (frame)->selected_window; + } +} + #endif /* HAVE_WINDOW_SYSTEM */ /* Update the tab-bar item list for frame F. This has to be done @@ -12681,7 +12691,7 @@ update_tab_bar (struct frame *f, bool save_match_d= ata) XFRAME (selected_frame)->selected_window)); #ifdef HAVE_WINDOW_SYSTEM Lisp_Object frame; - record_unwind_protect (fast_set_selected_frame, selected_frame); + record_unwind_protect (fast_set_selected_frame_if_live, selected_frame= ); XSETFRAME (frame, f); fast_set_selected_frame (frame); #endif @@ -13625,7 +13635,7 @@ update_tool_bar (struct frame *f, bool save_match_= data) /* Since we only explicitly preserve selected_frame, check that selected_window would be redundant. */ XFRAME (selected_frame)->selected_window)); - record_unwind_protect (fast_set_selected_frame, selected_frame); + record_unwind_protect (fast_set_selected_frame_if_live, selected_frame= ); XSETFRAME (frame, f); fast_set_selected_frame (frame); @@ -25009,9 +25019,14 @@ display_mode_lines (struct window *w) ++n; } - XFRAME (new_frame)->selected_window =3D old_frame_selected_window; - selected_frame =3D old_selected_frame; - selected_window =3D old_selected_window; + if (WINDOW_LIVE_P (old_frame_selected_window)) + XFRAME (new_frame)->selected_window =3D old_frame_selected_window; + if (FRAME_LIVE_P (XFRAME (old_selected_frame))) + { + selected_frame =3D old_selected_frame; + selected_window =3D old_selected_window; + } + if (n > 0) w->must_be_updated_p =3D true; return n; --------------D1A4A937170B4EA6EB2BB62D--