unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 13743@debbugs.gnu.org
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	[thread overview]
Message-ID: <512AFC18.4090504@yandex.ru> (raw)
In-Reply-To: <83ehg5k8xe.fsf@gnu.org>

On 24.02.2013 19:50, Eli Zaretskii wrote:
>> Date: Sun, 24 Feb 2013 19:28:32 +0400
>> From: Dmitry Gutov <dgutov@yandex.ru>
>> CC: Stefan Monnier <monnier@iro.umontreal.ca>, 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





  reply	other threads:[~2013-02-25  5:52 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-18  6:41 bug#13743: 24.2.93; Segmentation fault when trying to [s]teal a file opened elsewhere Dmitry Gutov
2013-02-18 16:11 ` Eli Zaretskii
2013-02-19  0:52   ` Dmitry Gutov
2013-02-20 19:31     ` Eli Zaretskii
2013-02-21  8:30       ` Dmitry Gutov
2013-02-18 19:35 ` Glenn Morris
2013-02-19  0:55   ` Dmitry Gutov
2013-02-21  5:16 ` Paul Eggert
2013-02-21  7:03   ` Dmitry Gutov
2013-02-23  3:37   ` Dmitry Gutov
2013-02-23 15:10     ` Eli Zaretskii
2013-02-23 16:59       ` Stefan Monnier
2013-02-23 18:44         ` Eli Zaretskii
2013-02-24 15:28           ` Dmitry Gutov
2013-02-24 15:50             ` Eli Zaretskii
2013-02-25  5:52               ` Dmitry Gutov [this message]
2013-02-25 15:25                 ` Stefan Monnier
2013-02-25 16:37                   ` Eli Zaretskii
2013-02-25 18:29                     ` Stefan Monnier
2013-02-25 18:56                       ` Eli Zaretskii
2013-02-25 20:28                         ` Stefan Monnier
2013-02-26  3:39                           ` Eli Zaretskii
2013-02-26  4:35                             ` Stefan Monnier
2013-03-02  9:30                               ` Eli Zaretskii
2013-02-25 16:25                 ` Eli Zaretskii
2013-02-25 18:27                   ` Dmitry Gutov
2013-02-25 16:27                 ` Eli Zaretskii
2013-02-25 19:08                   ` Dmitry Gutov
2013-02-25 19:31                     ` Eli Zaretskii
2013-02-25 23:23                       ` Dmitry Gutov
2013-02-26  3:51                         ` Eli Zaretskii
2013-02-26  3:59                           ` Dmitry Gutov
2013-02-26 18:42                             ` Eli Zaretskii
2013-02-27 17:46                               ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=512AFC18.4090504@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=13743@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).