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: Thu, 8 Apr 2021 20:52:29 +0200 Message-ID: <41cb6395-808f-8e82-ea47-db7a854aadee@gmx.at> References: <87im5ofp3z.fsf@md5i.com> <870479cc-efd3-3a19-98a3-1d7a8b9346e8@gmx.at> <79cfe67d-3a2c-952d-7c51-20e8a4859380@gmx.at> <87czv6q1f8.fsf@md5i.com> <233daa4b-ca64-955f-2612-49a0503b1938@gmx.at> <8735w2p8oc.fsf@md5i.com> <5181da75-e80d-22e0-bdcb-a0ffdc1bac6a@gmx.at> <5c4e5857-6a76-b8e8-204b-b4a855e95a16@gmx.at> <8f4516d5-1080-71bb-7da7-acf7832d5529@gmx.at> <87r1jlvnrc.fsf@md5i.com> <871rbkn6op.fsf@md5i.com> <83pmz493ag.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------F6C83CE53BABC6FE6E6523D0" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37240"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Michael Welsh Duggan , "schwab@linux-m68k.org" , "47244@debbugs.gnu.org" <47244@debbugs.gnu.org> To: Michael Welsh Duggan , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 08 20:53:11 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 1lUZmB-0009Xb-2n for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Apr 2021 20:53:11 +0200 Original-Received: from localhost ([::1]:39772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUZmA-0000WF-42 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Apr 2021 14:53:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUZm2-0000Ue-CV for bug-gnu-emacs@gnu.org; Thu, 08 Apr 2021 14:53:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36793) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUZm2-0004wJ-5m for bug-gnu-emacs@gnu.org; Thu, 08 Apr 2021 14:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lUZm2-0005PW-3y for bug-gnu-emacs@gnu.org; Thu, 08 Apr 2021 14:53: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: Thu, 08 Apr 2021 18:53: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.161790796720774 (code B ref 47244); Thu, 08 Apr 2021 18:53:02 +0000 Original-Received: (at 47244) by debbugs.gnu.org; 8 Apr 2021 18:52:47 +0000 Original-Received: from localhost ([127.0.0.1]:48338 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lUZlm-0005Oz-Ae for submit@debbugs.gnu.org; Thu, 08 Apr 2021 14:52:46 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]:49531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lUZlj-0005Oj-Ry for 47244@debbugs.gnu.org; Thu, 08 Apr 2021 14:52:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1617907952; bh=pNBlSNI69Dwl6zQeQa1Wp+oJJcPzfGmfxANNVudmDOQ=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=I2Q9I2MaHZSGHwzVtqGlatrKdiPE/HCBFTo73iV9vr5e1mUm3lXzPfpt7k7iP8qQv lEEntrEvQTaHNH+kA140xckOp0tz82WOmOQmd52KvYYal/ZI8pFAXyd7xVQ71dVNYJ 3zDxOB96EGSbUt9UhNH11E7LJ21TE9ErWELvHN/E= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [192.168.1.101] ([212.95.5.250]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MysRk-1lq4rC0acE-00vxhM; Thu, 08 Apr 2021 20:52:32 +0200 In-Reply-To: Content-Language: en-US X-Provags-ID: V03:K1:4DzoGDT8qDAPkKuV9oMPhgfOkNF3KpY5CiKqjOTeHlHMx3oV8Kd b48hvhisZjYiALnduyXU3aj9Wo4TeqwO30B0uy/ObHluwpQV9YW1kdIptFDVMPgPbqtjtr0 vbztFxfFC/XU4GBTEXYWa3IpMbdxbktcOOZMyHM9HwwrOtxdZpaLfsdJMRvjvqgMXugsG2A 8VEhgnrGFKe9BMii6iLaw== X-UI-Out-Filterresults: notjunk:1;V03:K0:a32BKpT1UyY=:1sZRHMfmJvCZk1PRFwNZfq fiuHSP3n4sX25GqGmQgCLMY61hjm6RuKKxXVC35G5YaSi8JBtch3wRzSGq0Lfi7f8TPTDvnxP zMxnCW7JovUL5CIRBvKucmQTmQ0JNo88F+qH3ygZQ/8FzD8E0q56TdeFfxJT9x696LcS82iT0 +/qaxProw4BvYA4jxyjl1uaiDwfIrR3EmekgPdJXnib5yCVdgupHTxTdouQ2bpd+YLHkhkvUt D1JMlAM3h6v4myI9yTvEo4r/0BzHjZeX0UCb3hQd5l9wdkzr8zV8TUhmGjbcQQ23LSvBeem6+ JuQ1PWKc4V9qS+rL7PVb5XRN6xicG5BmKA1Q0S2mEkjFC9zJszxmB5/ruHbMrXLM5DZSEA/2w xrZy+hBe35W2I8mJNXaQNwYv5XhfuqAOjwLfw9+nDq299X1DxZ5A5ls6T8t9qfmOMogEsQm91 hgKKdihjK2EvAuwXex2HjbNTolzb8k2TcjBRuSI3uCKqmFrMJCOAiAeoZFzOar/WWIpTy5+nw pjjSHPYlSyL8NcjfQgcBx3GvrwBNKRzUfHYnrf3qbHTRHrnk3NMtExxsOp+iEbgwX+0ygqy5A vDoC84rxiwWTdldujSBVmN46ZCcWbekTLcAXUzzH+zM0yZMoMIuKgm8EXc+LfHPsOFGsymk+g jkbxTWZhUg83wjR7iu21L4872yg0cMMnOwgQs7q+kmjnJQ/SJ8ODz0k8e7EBwxsZ3y4KC4FH+ M3UEX0pj65lMRvO5iQA9e7f4fwKcsP8qJQ9WGzId/gHsGZKzB+EBA56ma6D0R/Ulh0dLCZtM 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:203750 Archived-At: This is a multi-part message in MIME format. --------------F6C83CE53BABC6FE6E6523D0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit > I hit the breakpoint in quit. It looks like Fnconc uses FOR_EACH_TAIL, > which uses FOR_EACH_TAIL_INTENAL, which calls maybe_quit. Not just around the corner but near. Well done. > The question > in my mind now is whether block/unblock_input belongs in window_list or > in Fnconc. In window_list and we then should bind inhibit_quit IIUC. Fnconc must be able to deal with circular lists. I attach a patch. martin --------------F6C83CE53BABC6FE6E6523D0 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/nsfns.m b/src/nsfns.m index 5c4cc915e7..82136b0639 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1447,7 +1447,7 @@ Turn the input menu (an NSMenu) into a lisp list fo= r tracking on lisp side. =20 /* Make sure windows on this frame appear in calls to next-window and similar functions. */ - Vwindow_list =3D Qnil; + Vwindow_list =3D Vwindow_list_2 =3D Qnil; =20 return unbind_to (count, frame); } diff --git a/src/w32fns.c b/src/w32fns.c index 9db367bfaf..f2d5e34c3e 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -6148,7 +6148,7 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create= _frame, =20 /* Make sure windows on this frame appear in calls to next-window and similar functions. */ - Vwindow_list =3D Qnil; + Vwindow_list =3D Vwindow_list_2 =3D Qnil; =20 return unbind_to (count, frame); } diff --git a/src/window.c b/src/window.c index eb16e2a433..c858ddb4ff 100644 --- a/src/window.c +++ b/src/window.c @@ -86,6 +86,7 @@ Functions creating or deleting windows should invalidate this cache by setting it to nil. */ Lisp_Object Vwindow_list; +Lisp_Object Vwindow_list_2; =20 /* True mean window_change_record has to record all live frames. */ static bool window_change_record_frames; @@ -307,7 +308,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 +320,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 +600,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 @@ -2556,8 +2564,10 @@ window_list (void) if (!CONSP (Vwindow_list)) { Lisp_Object tail, frame; + ptrdiff_t count =3D SPECPDL_INDEX (); =20 Vwindow_list =3D Qnil; + specbind (Qinhibit_quit, Qt); FOR_EACH_FRAME (tail, frame) { Lisp_Object arglist =3D Qnil; @@ -2569,7 +2579,12 @@ window_list (void) arglist =3D Fnreverse (arglist); Vwindow_list =3D nconc2 (Vwindow_list, arglist); } + + Vwindow_list_2 =3D Fcopy_sequence (Vwindow_list); + unbind_to (count, Qnil); } + else + eassert (!NILP (Fequal (Vwindow_list, Vwindow_list_2))); =20 return Vwindow_list; } @@ -2950,6 +2965,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 +3065,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 @@ -3277,7 +3296,7 @@ DEFUN ("delete-other-windows-internal", Fdelete_oth= er_windows_internal, free_window_matrices (r); =20 fset_redisplay (f); - Vwindow_list =3D Qnil; + Vwindow_list =3D Vwindow_list_2 =3D Qnil; =20 if (!WINDOW_LEAF_P (w)) { @@ -3411,6 +3430,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 +3440,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 @@ -3960,6 +4002,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 +4098,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 @@ -4296,7 +4343,7 @@ make_window (void) w->scroll_bar_height =3D -1; w->column_number_displayed =3D -1; /* Reset window_list. */ - Vwindow_list =3D Qnil; + Vwindow_list =3D Vwindow_list_2 =3D Qnil; /* Return window. */ XSETWINDOW (window, w); return window; @@ -5086,7 +5133,7 @@ DEFUN ("delete-window-internal", Fdelete_window_int= ernal, Sdelete_window_interna } =20 fset_redisplay (f); - Vwindow_list =3D Qnil; + Vwindow_list =3D Vwindow_list_2 =3D Qnil; =20 wset_next (w, Qnil); /* Don't delete w->next too. */ free_window_matrices (w); @@ -5174,6 +5221,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 +7282,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 @@ -7279,7 +7331,7 @@ delete_all_child_windows (Lisp_Object window) wset_buffer (w, Qnil); } =20 - Vwindow_list =3D Qnil; + Vwindow_list =3D Vwindow_list_2 =3D Qnil; } =0C static ptrdiff_t @@ -8128,8 +8180,9 @@ init_window_once (void) selected_window =3D Qnil; staticpro (&selected_window); =20 - Vwindow_list =3D Qnil; + Vwindow_list =3D Vwindow_list_2 =3D Qnil; staticpro (&Vwindow_list); + staticpro (&Vwindow_list_2); =20 minibuf_selected_window =3D Qnil; staticpro (&minibuf_selected_window); @@ -8148,6 +8201,7 @@ init_window_once (void) PDUMPER_RESET_LV (minibuf_window, Qnil); PDUMPER_RESET_LV (selected_window, Qnil); PDUMPER_RESET_LV (Vwindow_list, Qnil); + PDUMPER_RESET_LV (Vwindow_list_2, Qnil); PDUMPER_RESET_LV (minibuf_selected_window, Qnil); =20 /* Hack: if mode_line_in_non_selected_windows is true (which it may @@ -8178,7 +8232,7 @@ init_window_once (void) void init_window (void) { - Vwindow_list =3D Qnil; + Vwindow_list =3D Vwindow_list_2 =3D Qnil; } =20 void diff --git a/src/window.h b/src/window.h index b6f88e8f55..74d3cbb7be 100644 --- a/src/window.h +++ b/src/window.h @@ -1171,6 +1171,7 @@ #define CHECK_LIVE_WINDOW(WINDOW) \ =20 /* These used to be in lisp.h. */ extern Lisp_Object Vwindow_list; +extern Lisp_Object Vwindow_list_2; =20 extern Lisp_Object window_list (void); extern Lisp_Object window_parameter (struct window *, Lisp_Object parame= ter); 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; diff --git a/src/xfns.c b/src/xfns.c index d90644819b..fbe9014555 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -4225,7 +4225,7 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create= _frame, =20 /* Make sure windows on this frame appear in calls to next-window and similar functions. */ - Vwindow_list =3D Qnil; + Vwindow_list =3D Vwindow_list_2 =3D Qnil; =20 return unbind_to (count, frame); } --------------F6C83CE53BABC6FE6E6523D0--