From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#13743: 24.2.93; Segmentation fault when trying to [s]teal a file opened elsewhere Date: Mon, 25 Feb 2013 09:52:24 +0400 Message-ID: <512AFC18.4090504@yandex.ru> References: <5125ADA9.3070603@cs.ucla.edu> <51283965.2020107@yandex.ru> <837glzkqvc.fsf@gnu.org> <83621ilvk9.fsf@gnu.org> <512A31A0.4040804@yandex.ru> <83ehg5k8xe.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1361771621 14930 80.91.229.3 (25 Feb 2013 05:53:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Feb 2013 05:53:41 +0000 (UTC) Cc: 13743@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 25 06:54:04 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U9r0k-0002s3-Vc for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Feb 2013 06:54:03 +0100 Original-Received: from localhost ([::1]:40977 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9r0P-0002q3-VX for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Feb 2013 00:53:41 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:50683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9r0L-0002pu-3f for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 00:53:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9r0I-0007SK-Kv for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 00:53:37 -0500 Original-Received: from [140.186.70.43] (port=43212 helo=debbugs.gnu.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9r0I-0007RG-Fz for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 00:53:34 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1U9r1i-0005PF-LJ for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 00:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 Feb 2013 05:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13743 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13743-submit@debbugs.gnu.org id=B13743.136177164820720 (code B ref 13743); Mon, 25 Feb 2013 05:55:02 +0000 Original-Received: (at 13743) by debbugs.gnu.org; 25 Feb 2013 05:54:08 +0000 Original-Received: from localhost ([127.0.0.1]:48675 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U9r0p-0005O9-W6 for submit@debbugs.gnu.org; Mon, 25 Feb 2013 00:54:08 -0500 Original-Received: from mail-la0-f50.google.com ([209.85.215.50]:41375) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U9r0m-0005O0-KU for 13743@debbugs.gnu.org; Mon, 25 Feb 2013 00:54:06 -0500 Original-Received: by mail-la0-f50.google.com with SMTP id ec20so2311630lab.37 for <13743@debbugs.gnu.org>; Sun, 24 Feb 2013 21:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=b3sa+13Fw8TQmqCtgafOeaEvbIW9RNVU45TOx3ry+OA=; b=ViLv/RB5Fd8YbeiOWLkKcdrJw5CMeF/iJBrPV01NuZ40rdHSNz4QC+1wC4NW7fv/oe ehbR6FetpZRhL1Ms/oWuDgwfD7frhZ9uPjATOKzcdeDDtP3Gu0NGmeY+/huYEoNGRP1n 9zMIEErfmaPwJepp024xuX4xP9cTxK7M429+JjwwbyUS3b0pK2fJ3QciH3TWHHCZXKaB gvvwdpRKtuqWA1wxZFrxI4P/1Sw/7BDALuJUgMAY/UG06vLyNrO0k9if8GtCITIopMMG lyPUuUXlEG/BsbJv+kc92ixxkUS/mf9QfwX3+WV1DojefYa5r1hlSBIADN9PDesUKg85 uUHg== X-Received: by 10.112.104.103 with SMTP id gd7mr3968634lbb.54.1361771546066; Sun, 24 Feb 2013 21:52:26 -0800 (PST) Original-Received: from [127.0.0.1] ([178.252.98.87]) by mx.google.com with ESMTPS id oy10sm6124239lab.8.2013.02.24.21.52.24 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 24 Feb 2013 21:52:24 -0800 (PST) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 In-Reply-To: <83ehg5k8xe.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:71765 Archived-At: On 24.02.2013 19:50, Eli Zaretskii wrote: >> Date: Sun, 24 Feb 2013 19:28:32 +0400 >> From: Dmitry Gutov >> CC: Stefan Monnier , 13743@debbugs.gnu.org >> >>>> How 'bout moving the >>>> >>>> if (BUFFERP (object)) >>>> modify_region (object, start, end); >>>> >>>> earlier in the function. Something like the patch below. >>> >>> This will (falsely, AFAIU) tell us that the region is about to be >>> modified when we return at the point marked below: >> >> I tried the patches, and both seem to work fine so far. If you could >> explain the practical implications of the drawback in Stefan's patch >> you're describing here, I'll try to test for that, too. > > You need to simulate the situation which causes us to return here: > >>> /* If this interval already has the properties, we can >>> skip it. */ >>> if (interval_has_all_properties (properties, i)) >>> { >>> ptrdiff_t got = (LENGTH (i) - (s - i->position)); >>> if (got >= len) >>> RETURN_UNGCPRO (Qnil); <<<<<<<<<<<<<<<<<<<<<<<<<<< > > This condition means that we find an interval which already has the > property we are trying to add, and that interval's length is at least > as large as the distance between START and END. > > The simplest thing to try reproducing this would be to call > add-text-properties with the property that is already somewhere in the > buffer and with START and END that belong to the buffer region with > this property. I hope this will show you what happens. Thanks. > The manifestation of the problem will be that modify_region will be > called in this case, although we don't actually modify anything. You > will probably see the "modified" indicator on the mode line, something > that shouldn't have happened. That is indeed what happens. OTOH, the existing behavior in this area is rather messy anyway: a) If START equals to the beginning of the region with the same property, the buffer is marked modified anyway (even though nothing changes from the observer's point of view). So, the trivial example of repeating an `add-text-properties' call with the same arguments in a previously unpropertized buffer will mark it as modified every time. b) This probably has something to do with internal representation, but even having the same property span before START is not a safe bet: 1. Create a new file with a line of text in it, preferably without spaces, to see face changes easily 2. Save it, disable font-lock-mode. 3. Evaluate: (add-text-properties 1 6 '(face font-lock-constant-face)) => modified save (add-text-properties 2 6 '(face font-lock-constant-face)) => unmodified (add-text-properties 2 7 '(face font-lock-constant-face)) => modified save (add-text-properties 2 6 '(face font-lock-constant-face)) => unmodified - optional step (add-text-properties 2 7 '(face font-lock-constant-face)) => modified(!) - even though 1 still has the same face - you can save and repeat this step indefinitely