From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Effect of deletions on indirect buffers (Bug#8219) Date: Fri, 11 Mar 2011 14:48:21 -0500 Message-ID: <877hc5bfqy.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1299872921 14491 80.91.229.12 (11 Mar 2011 19:48:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 11 Mar 2011 19:48:41 +0000 (UTC) Cc: 8219@debbugs.gnu.org To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 11 20:48:37 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Py8KB-0001dn-Ro for ged-emacs-devel@m.gmane.org; Fri, 11 Mar 2011 20:48:36 +0100 Original-Received: from localhost ([127.0.0.1]:33982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Py8KB-0006kq-El for ged-emacs-devel@m.gmane.org; Fri, 11 Mar 2011 14:48:35 -0500 Original-Received: from [140.186.70.92] (port=34651 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Py8K5-0006kk-TY for emacs-devel@gnu.org; Fri, 11 Mar 2011 14:48:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Py8K4-0001g9-Qd for emacs-devel@gnu.org; Fri, 11 Mar 2011 14:48:29 -0500 Original-Received: from vm-emlprdomr-05.its.yale.edu ([130.132.50.146]:33553) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Py8K4-0001fw-Oe for emacs-devel@gnu.org; Fri, 11 Mar 2011 14:48:28 -0500 Original-Received: from furball (dhcp128036014143.central.yale.edu [128.36.14.143]) (authenticated bits=0) by vm-emlprdomr-05.its.yale.edu (8.14.4/8.14.4) with ESMTP id p2BJmL4m007519 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 11 Mar 2011 14:48:21 -0500 Original-Received: by furball (Postfix, from userid 1000) id A19181603F0; Fri, 11 Mar 2011 14:48:21 -0500 (EST) X-Scanned-By: MIMEDefang 2.71 on 130.132.50.146 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 130.132.50.146 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:137122 Archived-At: Indirect bufffers are allowed to have their own values of point, BUF_BEGV, and BUF_ZV (indeed, that's one of their roles). Their other attributes inherit from the base buffer, e.g. #define BUF_Z(buf) ((buf)->text->z) where `text' points to the base buffer's text object. Now consider what happens when a deletion is performed in buffer A, which is the base buffer for an indirect buffer B. It appears that the responsible functions, such as del_range_2, only update the attributes of buffer A, making no effort to update buffer B. Hence, in the aftermath of a deletion, buffer B's values of PT (and BUF_BEGV and BUF_ZV) can be larger than BUF_ZV. This is the proximate cause of the crash in Bug#8219: there, we have if (prev_pt > BUF_BEGV (buf) && prev_pt < BUF_ZV (buf) && find_composition (prev_pt, -1, &start, &end, &prop, buffer) and find_composition aborts because prev_pt is larger than the size of the buffer. I'm not sure what the best solution is. The narrowest fix is to change find_composition, and the functions it calls, so that it does not abort when supplied with a position that's beyond BUF_Z. This might be the best approach for the emacs-23 branch. However, I suspect that we have other places in the code that assumes that if a point is smaller than BUF_ZV, it's necessarily smaller than BUF_Z---which we now see if not that case. So, a more comprehensive fix is needed for the trunk. Any thoughts?