From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#47244: 28.0.50; SIGSEGV in long-runnning Emacs Date: Fri, 2 Apr 2021 08:48:35 +0200 Message-ID: <7a37c708-0ac1-3b06-9042-b4b2b6d6c5d6@gmx.at> References: <87im5ofp3z.fsf@md5i.com> <83y2e6kp9t.fsf@gnu.org> <83tuouknpb.fsf@gnu.org> <83sg4eknh5.fsf@gnu.org> <83r1jykmt0.fsf@gnu.org> <2d0dbdc8-3678-cd21-234a-9c63bb004629@gmx.at> <834kgrifrt.fsf@gnu.org> <106ce987-1a45-bbdf-3897-445baa99a476@gmx.at> <745cb501-d742-8797-d07c-00125f60f8ec@gmx.at> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------D8A962A8140476BC29ECAFFA" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20447"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "mwd@md5i.com" , "schwab@linux-m68k.org" , "47244@debbugs.gnu.org" <47244@debbugs.gnu.org> To: Michael Welsh Duggan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 02 08:49:30 2021 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 1lSDcY-0005Dm-5d for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Apr 2021 08:49:30 +0200 Original-Received: from localhost ([::1]:38824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lSDcX-0001KL-4D for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Apr 2021 02:49:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lSDc6-0001KA-D9 for bug-gnu-emacs@gnu.org; Fri, 02 Apr 2021 02:49:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47463) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lSDc6-00078n-4e for bug-gnu-emacs@gnu.org; Fri, 02 Apr 2021 02:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lSDc6-0000sh-2L for bug-gnu-emacs@gnu.org; Fri, 02 Apr 2021 02:49: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: Fri, 02 Apr 2021 06:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47244 X-GNU-PR-Package: emacs Original-Received: via spool by 47244-submit@debbugs.gnu.org id=B47244.16173461353371 (code B ref 47244); Fri, 02 Apr 2021 06:49:02 +0000 Original-Received: (at 47244) by debbugs.gnu.org; 2 Apr 2021 06:48:55 +0000 Original-Received: from localhost ([127.0.0.1]:59009 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lSDby-0000sI-Mv for submit@debbugs.gnu.org; Fri, 02 Apr 2021 02:48:55 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:44925) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lSDbw-0000s2-Da for 47244@debbugs.gnu.org; Fri, 02 Apr 2021 02:48:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1617346118; bh=qlbvLE9vFwZZqTUkne9CzPpi4NU2vncXmkDNV+7r9vg=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=c6ZkTuYSJ7R6h3sQWTOGttICUacLyd8iKUoPJqgqSscdJDa1B4PiJuEXKoUCpGQ/s Hq4f24sYQ2Bm1rbhcp6dbXilg+n2RrWn34vr2/GChEnqd8+DNP4wj6vTMLK5dynt3a tJfcd1szFj6VjlN9eBtm9oHnCBefPD7eTo4FII04= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [192.168.1.100] ([212.95.5.7]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M4axg-1lQYue0DeY-001fNg; Fri, 02 Apr 2021 08:48:38 +0200 In-Reply-To: Content-Language: en-US X-Provags-ID: V03:K1:/hke/hlTcmh+a4qj46CIY2+XTRB0RFC9LX8pberDt0Pi8pzv27q TOvC3KptGTXmOm9Iw5FlKjSE0xi1UdG4+15FAdn3fc+MvXpanovLqSNvZWz/AA+rmuwBDmB Y8HhA+2Qhj4OgV5COsz/r7eGdORFYhcRxnB97+1IJIzOqBh0CvtaSJcKCKMp0Jrt2e/hiRQ qoC7kvRmvuUeM3GJ9yTIQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:CsUi4RlglzA=:9K3Gxjxr2XJMZAXkuxQFqT MqHBBcYb3XD/ifVhLaR1CePip6W1Yb16lliTRUmYt+hNHIeZ/b7BXVN6K7ZdrqLZdoAn4uLWO /qPtoLbjqu2U2+Hd8pSOhuen57jS6yPvFuUIgL1+CwUcHTEwEYh+ELlQ2icEeq6aB1szOO/jv UbEwA0A+/WDIbeCLN/f7jZBBYTtm75Ri0mAF/yZdGmHjNOVVR2k8ekmPC/5mPEExDdRgVxMpw cIuOXmFQIjbmsf8xEB5GB3DidfkX3cwPSJVBNwiRkwJEt+lURVZO4KkViNOwrmkkCVtQ9/KPD tqBIehwT0l/uMteQGPJmCsG8of9E+sJ6RPKfG7+6JIEOXEF7XTTxuF7BaSkeVkeRDpsuaVigt TKlwWKP8dpawc9GYhsNtG4rweHmc0HvTjYnxLy+5rKO0HCwftZ0IZqeZyFI4vk3B157GbyBTM sIYkfrzEYQUBuOMYhOnsQwh5urApWRAg3vITsjs9WXeR7jJkBUThGc53luXtVqZjM5+j23zOk 6HIPznbO9r8o0nlLBWA+1uEku5+OJe5z1kmsfHZGuvSpbSFsLNIPGvEuxpAS/uGR4C9dnwLQp CINmvslYVeOh+2Su7hzMDHc6SPAaRyz2Pg6PVHNLSP3+tyvH7phx81u1fg4RQCdzK6yRD+dMb MctrlAy2TyREOATRZYC/jSR70eH0OYdAlh5L8MHMKEnJ3o/VIv1WZ63Tue2gyv/1MtALPVP2O Hz/lDsMYwrisPoyYWAVFmoYZBPerUM8QRQfzVOaUAChKLXNKpZpskmMkcJt9U8XwAi9HQkj/ 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" Xref: news.gmane.io gmane.emacs.bugs:203462 Archived-At: This is a multi-part message in MIME format. --------------D8A962A8140476BC29ECAFFA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit > The answer, which I sort of suspected, is that it never hit that > breakpoint at all before the assertion fires. You're right. In + if (!NILP (Fstring_equal (XBUFFER (w->contents)->name_, + build_string ("*Server*")))) + best_window = Qt; + /* Undedicate WINDOW. */ wset_dedicated (w, Qnil); /* Make WINDOW show the buffer returned by @@ -3048,6 +3061,8 @@ window_loop (enum window_loop type, Lisp_Object obj, bool mini, if (EQ (window, selected_window) && XBUFFER (w->contents) == current_buffer) Fset_buffer (w->contents); + + replace_buffer_in_windows_safely_count += 1; replace_buffer_in_windows_safely_count is incremented regardless of whether W's buffer is *Server* or not. In either case the assertion would not fail. So once we are here everything is all right and the bug must be that we do not get here. I attach the next patch. Please put a breakpoint at the replace_buffer_in_windows_safely_count = 0; and try to step through the rest of this function with GDB. And if you don't hit it, the detection logic went wrong ... martin --------------D8A962A8140476BC29ECAFFA Content-Type: text/x-patch; name="selected_window_contents.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="selected_window_contents.diff" diff --git a/src/buffer.c b/src/buffer.c index 8e33162989..70b37e61a2 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1951,6 +1951,9 @@ DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0= , 1, "bKill buffer: ", This gets rid of them for certain. */ reset_buffer_local_variables (b, 1); =20 + if (!b->base_buffer) + eassert (b->window_count =3D=3D 0); + bset_name (b, Qnil); =20 block_input (); @@ -1991,6 +1994,8 @@ DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0= , 1, "bKill buffer: ", =20 run_buffer_list_update_hook (b); =20 + eassert (BUFFER_LIVE_P (XBUFFER (XWINDOW (selected_window)->contents))= ); + return Qt; } =0C @@ -2151,6 +2156,9 @@ set_buffer_internal_1 (register struct buffer *b) =20 BUFFER_CHECK_INDIRECTION (b); =20 + if (!BUFFER_LIVE_P (b)) + error ("Selecting deleted buffer"); + old_buf =3D current_buffer; current_buffer =3D b; last_known_column_point =3D -1; /* Invalidate indentation cache. */= diff --git a/src/window.c b/src/window.c index eb16e2a433..aa69c66be6 100644 --- a/src/window.c +++ b/src/window.c @@ -307,7 +307,11 @@ wset_buffer (struct window *w, Lisp_Object val) if (BUFFERP (val)) /* Make sure that we do not assign the buffer to an internal window. */ - eassert (MARKERP (w->start) && MARKERP (w->pointm)); + { + eassert (BUFFER_LIVE_P (XBUFFER (val))); + eassert (MARKERP (w->start) && MARKERP (w->pointm)); + } + w->contents =3D val; adjust_window_count (w, 1); } @@ -315,6 +319,7 @@ wset_buffer (struct window *w, Lisp_Object val) static void wset_old_buffer (struct window *w, Lisp_Object val) { + eassert (BUFFER_LIVE_P (XBUFFER (val))); w->old_buffer =3D val; } =20 @@ -594,6 +599,8 @@ select_window_1 (Lisp_Object window, bool inhibit_poi= nt_swap) =20 selected_window =3D window; =20 + eassert (BUFFER_LIVE_P (XBUFFER (XWINDOW (selected_window)->contents))= ); + /* Go to the point recorded in the window. This is important when the buffer is in more than one window. It also matters when @@ -2950,6 +2957,8 @@ DEFUN ("window-list-1", Fwindow_list_1, Swindow_lis= t_1, 0, 3, 0, CHECK_ALL_WINDOWS /* Arg is ignored */ }; =20 +static int replace_buffer_in_windows_safely_count; + static Lisp_Object window_loop (enum window_loop type, Lisp_Object obj, bool mini, Lisp_Object frames) @@ -3048,6 +3057,8 @@ window_loop (enum window_loop type, Lisp_Object obj= , bool mini, if (EQ (window, selected_window) && XBUFFER (w->contents) =3D=3D current_buffer) Fset_buffer (w->contents); + + replace_buffer_in_windows_safely_count +=3D 1; } break; =20 @@ -3411,6 +3422,8 @@ DEFUN ("delete-other-windows-internal", Fdelete_oth= er_windows_internal, replace_buffer_in_windows (Lisp_Object buffer) { call1 (Qreplace_buffer_in_windows, buffer); + + eassert (BUFFER_LIVE_P (XBUFFER (XWINDOW (selected_window)->contents))= ); } =20 /* If BUFFER is shown in a window, safely replace it with some other @@ -3419,7 +3432,28 @@ replace_buffer_in_windows (Lisp_Object buffer) void replace_buffer_in_windows_safely (Lisp_Object buffer) { - if (buffer_window_count (XBUFFER (buffer))) + if (!NILP (Fstring_equal (XBUFFER (buffer)->name_, + build_string ("*Server*")))) + { + int count =3D buffer_window_count (XBUFFER (buffer)); + + replace_buffer_in_windows_safely_count =3D 0; + + + if (buffer_window_count (XBUFFER (buffer))) + { + Lisp_Object tail, frame; + + /* A single call to window_loop won't do the job because it only + considers frames on the current keyboard. So loop manually over + frames, and handle each one. */ + FOR_EACH_FRAME (tail, frame) + window_loop (REPLACE_BUFFER_IN_WINDOWS_SAFELY, buffer, true, frame)= ; + } + + eassert (count =3D=3D replace_buffer_in_windows_safely_count); + } + else if (buffer_window_count (XBUFFER (buffer))) { Lisp_Object tail, frame; =20 @@ -3429,6 +3463,7 @@ replace_buffer_in_windows_safely (Lisp_Object buffe= r) FOR_EACH_FRAME (tail, frame) window_loop (REPLACE_BUFFER_IN_WINDOWS_SAFELY, buffer, true, frame); } + } =0C /* The following three routines are needed for running a window's @@ -3960,6 +3995,8 @@ run_window_change_functions (void) /* Record changes for all frames (if asked for), selected window and frame. */ unbind_to (count, Qnil); + + eassert (BUFFER_LIVE_P (XBUFFER (XWINDOW (selected_window)->contents))= ); } =20 /* Make WINDOW display BUFFER. RUN_HOOKS_P means it's allowed @@ -4054,6 +4091,9 @@ set_window_buffer (Lisp_Object window, Lisp_Object = buffer, if (!samebuf && !MINI_WINDOW_P (w) && !WINDOW_PSEUDO_P (w)) FRAME_WINDOW_CHANGE (XFRAME (w->frame)) =3D true; =20 + if (WINDOWP (selected_window)) + eassert (BUFFER_LIVE_P (XBUFFER (XWINDOW (selected_window)->contents= ))); + unbind_to (count, Qnil); } =20 @@ -5174,6 +5214,8 @@ DEFUN ("delete-window-internal", Fdelete_window_int= ernal, Sdelete_window_interna error ("Deletion failed"); } =20 + eassert (BUFFER_LIVE_P (XBUFFER (XWINDOW (selected_window)->contents))= ); + return Qnil; } =0C @@ -7233,6 +7275,9 @@ DEFUN ("set-window-configuration", Fset_window_conf= iguration, minibuf_selected_window =3D data->minibuf_selected_window; =20 SAFE_FREE (); + + eassert (BUFFER_LIVE_P (XBUFFER (XWINDOW (selected_window)->contents))= ); + return FRAME_LIVE_P (f) ? Qt : Qnil; } =20 diff --git a/src/xdisp.c b/src/xdisp.c index cc0a689ba3..ea64e5037a 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -12980,6 +12980,8 @@ restore_selected_window (Lisp_Object window) /* Abort if we cannot find a live frame. */ emacs_abort (); } + + eassert (BUFFER_LIVE_P (XBUFFER (XWINDOW (selected_window)->contents))= ); } =20 /* Restore WINDOW, if live, as its frame's selected window. */ @@ -12997,6 +12999,8 @@ restore_frame_selected_window (Lisp_Object window= ) if (EQ (frame, selected_frame)) selected_window =3D window; } + + eassert (BUFFER_LIVE_P (XBUFFER (XWINDOW (selected_window)->contents))= ); } =20 /* Update the tab-bar item list for frame F. This has to be done @@ -13074,6 +13078,8 @@ update_tab_bar (struct frame *f, bool save_match_= data) XSETFRAME (frame, f); selected_frame =3D frame; selected_window =3D FRAME_SELECTED_WINDOW (f); + + eassert (BUFFER_LIVE_P (XBUFFER (XWINDOW (selected_window)->contents)= )); #endif =20 /* Build desired tab-bar items from keymaps. */ @@ -14010,6 +14016,8 @@ update_tool_bar (struct frame *f, bool save_match= _data) selected_frame =3D frame; selected_window =3D FRAME_SELECTED_WINDOW (f); =20 + eassert (BUFFER_LIVE_P (XBUFFER (XWINDOW (selected_window)->contents)= )); + /* Build desired tool-bar items from keymaps. */ new_tool_bar =3D tool_bar_items (Fcopy_sequence (f->tool_bar_items), @@ -17246,6 +17254,8 @@ run_window_scroll_functions (Lisp_Object window, = struct text_pos startp) set_buffer_internal (XBUFFER (w->contents)); } =20 + eassert (BUFFER_LIVE_P (XBUFFER (XWINDOW (selected_window)->contents))= ); + return startp; } =20 @@ -25450,6 +25460,8 @@ display_mode_lines (struct window *w) =20 unbind_to (count, Qnil); =20 + eassert (BUFFER_LIVE_P (XBUFFER (XWINDOW (selected_window)->contents))= ); + if (n > 0) w->must_be_updated_p =3D true; return n; --------------D8A962A8140476BC29ECAFFA--