From: Derek Upham <sand@blarg.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Noam Postavsky <npostavs@gmail.com>, 32265@debbugs.gnu.org
Subject: bug#32265: 26.1; yank-excluded-properties set to t triggers "Error in syntax_table logic for intervals <-" signal
Date: Wed, 01 Aug 2018 06:54:03 -0700 [thread overview]
Message-ID: <87zhy6fb0k.fsf@priss.frightenedpiglet.com> (raw)
In-Reply-To: <8336vyo0jj.fsf@gnu.org>
> If the patch below fixes the original problem (Derek, can you
> confirm?), I will install it on the emacs-26 branch.
Will do. Is the patch against the stock 26.1 sources, or against some other commit?
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Noam Postavsky <npostavs@gmail.com>
>> Cc: sand@blarg.net, 32265@debbugs.gnu.org
>> Date: Tue, 31 Jul 2018 21:06:08 -0400
>>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>> > I presume just calling set-text-properties with the same arguments
>> > there doesn't trigger the problem? If so, I think we need to
>> > understand how come we got offset=-1 in frame #4.
>>
>> Actually, it looks like it can be triggered with just
>> set-text-properties, but there is some interaction with
>> c-before-change. I've reduced the testcase to this:
>>
>> (defconst dir (file-name-directory
>> (or load-file-name buffer-file-name)))
>>
>> (pop-to-buffer-same-window (get-buffer-create "*test*"))
>> (erase-buffer)
>> (insert-file-contents (expand-file-name "U.java" dir))
>> (java-mode)
>> (set-text-properties 10467 10542 nil)
>
> Thanks for an easy test case. This is bug #13743 striking again in a
> slightly different incarnation: removing the text properties calls
> before-change-functions, which modify the buffer's interval tree, but
> we continue using the interval calculated from the unmodified tree.
> So the solution should be similar to what we used in that bug.
>
> If the patch below fixes the original problem (Derek, can you
> confirm?), I will install it on the emacs-26 branch.
>
>> The backtrace no longer has a negative offset to blame:
>>
>> ../../src/intervals.c:371: Emacs fatal error: assertion failed: LENGTH (i) > 0
>>
>> (gdb) bt 8
>> #0 terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at ../../src/emacs.c:364
>> #1 0x00000000006161d3 in die (msg=0x7795cd "LENGTH (i) > 0", file=0x7794f0 "../../src/intervals.c",
>> line=371) at ../../src/alloc.c:7410
>> #2 0x00000000006b51c4 in balance_an_interval (i=0x324b0b0) at ../../src/intervals.c:371
>> #3 0x00000000006b5792 in split_interval_right (interval=0x181f380 <bss_sbrk_buffer+10524736>,
>> offset=4048) at ../../src/intervals.c:504
>
> But the offset is still bogus, because:
>
> #3 0x012d2f46 in split_interval_right (interval=0xfa9c10, offset=4048)
> at intervals.c:504
> 504 balance_an_interval (new);
> (gdb) p new_length
> $8 = -107
>
> IOW, OFFSET is greater than LENGTH(interval) in split_interval_right,
> which must not happen.
>
> Here's the proposed patch:
>
> diff --git a/src/textprop.c b/src/textprop.c
> index 984f2e6..904e226 100644
> --- a/src/textprop.c
> +++ b/src/textprop.c
> @@ -1350,6 +1350,7 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties,
> {
> register INTERVAL i;
> Lisp_Object ostart, oend;
> + bool first_time = true;
>
> ostart = start;
> oend = end;
> @@ -1372,6 +1373,7 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties,
> return Qt;
> }
>
> + retry:
> i = validate_interval_range (object, &start, &end, soft);
>
> if (!i)
> @@ -1391,8 +1393,22 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties,
> return Qnil;
> }
>
> - if (BUFFERP (object) && !NILP (coherent_change_p))
> - modify_text_properties (object, start, end);
> + if (BUFFERP (object) && !NILP (coherent_change_p) && first_time)
> + {
> + ptrdiff_t prev_length = LENGTH (i);
> + ptrdiff_t prev_pos = i->position;
> +
> + modify_text_properties (object, start, end);
> + /* If someone called us recursively as a side effect of
> + modify_text_properties, and changed the intervals behind our
> + back, we cannot continue with I, because its data changed.
> + So we restart the interval analysis anew. */
> + if (LENGTH (i) != prev_length || i->position != prev_pos)
> + {
> + first_time = false;
> + goto retry;
> + }
> + }
>
> set_text_properties_1 (start, end, properties, object, i);
>
next prev parent reply other threads:[~2018-08-01 13:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-25 5:15 bug#32265: 26.1; yank-excluded-properties set to t triggers "Error in syntax_table logic for intervals <-" signal Derek Upham
2018-07-31 12:04 ` Noam Postavsky
2018-07-31 16:15 ` Eli Zaretskii
2018-08-01 1:06 ` Noam Postavsky
2018-08-01 10:15 ` Eli Zaretskii
2018-08-01 13:54 ` Derek Upham [this message]
2018-08-01 15:38 ` Eli Zaretskii
2018-08-02 4:44 ` Derek Upham
2018-08-02 13:31 ` Eli Zaretskii
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zhy6fb0k.fsf@priss.frightenedpiglet.com \
--to=sand@blarg.net \
--cc=32265@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=npostavs@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.