From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Edebug corrupting point in buffers. Date: Tue, 1 Nov 2022 19:02:24 +0000 Message-ID: References: <83wn8fcgvd.fsf@gnu.org> <83iljydh7e.fsf@gnu.org> <838rkud9d5.fsf@gnu.org> <83v8nybnuk.fsf@gnu.org> <83pme6bls8.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12636"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 01 20:03:21 2022 Return-path: Envelope-to: ged-emacs-devel@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 1opwXh-00033I-7h for ged-emacs-devel@m.gmane-mx.org; Tue, 01 Nov 2022 20:03:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opwWv-0000gt-D1; Tue, 01 Nov 2022 15:02:33 -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 1opwWu-0000fY-7l for emacs-devel@gnu.org; Tue, 01 Nov 2022 15:02:32 -0400 Original-Received: from mx3.muc.de ([193.149.48.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opwWs-0004nY-0i for emacs-devel@gnu.org; Tue, 01 Nov 2022 15:02:32 -0400 Original-Received: (qmail 9595 invoked by uid 3782); 1 Nov 2022 20:02:26 +0100 Original-Received: from acm.muc.de (p4fe15c46.dip0.t-ipconnect.de [79.225.92.70]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 01 Nov 2022 20:02:25 +0100 Original-Received: (qmail 8251 invoked by uid 1000); 1 Nov 2022 19:02:24 -0000 Content-Disposition: inline In-Reply-To: <83pme6bls8.fsf@gnu.org> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.5; envelope-from=acm@muc.de; helo=mx3.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298969 Archived-At: Hello, Eli. On Tue, Nov 01, 2022 at 19:57:11 +0200, Eli Zaretskii wrote: > > Date: Tue, 1 Nov 2022 17:24:26 +0000 > > Cc: emacs-devel@gnu.org > > From: Alan Mackenzie > > > (defcustom edebug-save-displayed-buffer-points nil > > > "If non-nil, save and restore point in all displayed buffers. > > > What am I missing? > > The troublesome behaviour is controlled by edebug-save-windows, not > > edebug-save-displayed-buffer-points. edebug-save-windows is enabled by > > default. Sorry for not reading your post more carefully. > This now gets me back to the inability to reproduce the problem with > your recipe. If that depends on edebug-save-windows, not on > edebug-save-displayed-buffer-points, and since edebug-save-windows is > t by default, why wasn't I able to reproduce the problem? I don't know. Have you tried again? > Anyway, the documentation of edebug-save-windows says: > -- User Option: edebug-save-windows > If this is non-‘nil’, Edebug saves and restores the window > configuration. That takes some time, so if your program does not > care what happens to the window configurations, it is better to set > this variable to ‘nil’. > If the value is a list, only the listed windows are saved and > restored. > So I'm now asking whether setting edebug-save-windows to nil would > have solved your problem, and if so, whether we really need some > bugfix and a new varaiable? Well, it seems at the moment that my problem was caused by set-window-configuration, in that not only does it restore the stored window configuration, it also overwrites the buffer-points for all but the current buffer. That is the mechanism of the corruption of the buffer-points, which I detailed earlier. Why does set-window-configuration overwrite the buffer-points? The window configuration does not contain them. The code just assumes that the buffer-point should be set to the window point. Of course, we have a race condition if a buffer is displayed in several windows. So this would appear to be a bug, the root cause of the bug in this thread. Maybe set-window-configuration should be amended not to write the buffer-points? That might cause problems in other areas, though. The window configuration is one of the few areas where the documentation is poor enough that you need to read the C source to find out what it's really doing. To come back to your two questions, I honestly don't know if setting edebug-save-windows to nil would have prevented the problem. I think so, but I'm not sure. The original bug is an arduous bug to set up. Whether we need a bugfix, I would say definitely yes. There is no way that a user faced with this corruption of a buffer-point would somehow say "Ah, window configurations! That's what's going wrong". Maybe we could fix it by documenting the precise situation in the Elisp manual, possibly combined with making edebug-save-windows nil by default. Or maybe the patch to the code is a safer, more direct fix. After all, edebug is the system debugger, the tool of last resort. It should not fail at all. -- Alan Mackenzie (Nuremberg, Germany).