From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Derek Upham Newsgroups: gmane.emacs.bugs 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 Message-ID: <87zhy6fb0k.fsf@priss.frightenedpiglet.com> References: <87lg9zgal6.fsf@priss.frightenedpiglet.com> <87lg9r1uil.fsf@gmail.com> <83va8vnzz2.fsf@gnu.org> <87a7q628vz.fsf@gmail.com> <8336vyo0jj.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1533131683 27758 195.159.176.226 (1 Aug 2018 13:54:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 1 Aug 2018 13:54:43 +0000 (UTC) User-Agent: mu4e 0.9.17; emacs 25.2.2 Cc: Noam Postavsky , 32265@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Aug 01 15:54:38 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fkraH-00076l-Tl for geb-bug-gnu-emacs@m.gmane.org; Wed, 01 Aug 2018 15:54:38 +0200 Original-Received: from localhost ([::1]:40881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkrcO-0001Vx-Nu for geb-bug-gnu-emacs@m.gmane.org; Wed, 01 Aug 2018 09:56:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkral-0000Lo-Iv for bug-gnu-emacs@gnu.org; Wed, 01 Aug 2018 09:55:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fkrah-0002jS-KJ for bug-gnu-emacs@gnu.org; Wed, 01 Aug 2018 09:55:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60313) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fkrah-0002jG-BO for bug-gnu-emacs@gnu.org; Wed, 01 Aug 2018 09:55:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fkrah-0005dZ-0P for bug-gnu-emacs@gnu.org; Wed, 01 Aug 2018 09:55:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Derek Upham Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Aug 2018 13:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32265 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 32265-submit@debbugs.gnu.org id=B32265.153313164721593 (code B ref 32265); Wed, 01 Aug 2018 13:55:02 +0000 Original-Received: (at 32265) by debbugs.gnu.org; 1 Aug 2018 13:54:07 +0000 Original-Received: from localhost ([127.0.0.1]:37097 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fkrZm-0005cD-Mi for submit@debbugs.gnu.org; Wed, 01 Aug 2018 09:54:06 -0400 Original-Received: from smtp61.avvanta.com ([206.124.128.61]:58016 helo=mail.avvanta.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fkrZl-0005c5-Gj for 32265@debbugs.gnu.org; Wed, 01 Aug 2018 09:54:06 -0400 Original-Received: from mail.avvanta.com (localhost.drteeth.p.blarg.net [127.0.0.1]) by mail.avvanta.com (Postfix) with ESMTP id 67779F3938; Wed, 1 Aug 2018 06:53:11 -0700 (PDT) Original-Received: from priss.frightenedpiglet.com (c-73-83-45-232.hsd1.wa.comcast.net [73.83.45.232]) by mail.avvanta.com (Postfix) with ESMTP id 50E05F3935; Wed, 1 Aug 2018 06:53:11 -0700 (PDT) Original-Received: from localhost ([127.0.0.1] helo=priss.frightenedpiglet.com) by priss.frightenedpiglet.com with esmtp (Exim 4.91) (envelope-from ) id 1fkrZj-0007h9-8v; Wed, 01 Aug 2018 06:54:03 -0700 In-reply-to: <8336vyo0jj.fsf@gnu.org> X-BlargAV-Status: No viruses detected, BlargAV v1.1 on localhost.drteeth.p.blarg.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:149173 Archived-At: > 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 writes: >> From: Noam Postavsky >> Cc: sand@blarg.net, 32265@debbugs.gnu.org >> Date: Tue, 31 Jul 2018 21:06:08 -0400 >> >> Eli Zaretskii 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 , >> 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); >