GNU bug report logs - #36897
27.0.50; [CC Mode] c-after-change may signal error in narrowed buffer

Previous Next

Package: emacs;

Reported by: Noam Postavsky <npostavs <at> gmail.com>

Date: Fri, 2 Aug 2019 00:31:01 UTC

Severity: normal

Tags: fixed

Merged with 36898

Found in version 27.0.50

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 36897 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 36897 <at> debbugs.gnu.org
Subject: Re: bug#36897: 27.0.50;
 [CC Mode] c-after-change may signal error in narrowed buffer
Date: 2 Aug 2019 08:41:21 -0000
Hello, Noam.

In article <mailman.507.1564705872.1985.bug-gnu-emacs <at> gnu.org> you wrote:
> [-- text/plain, encoding 7bit, charset: US-ASCII, 31 lines --]

> Package: emacs, cc-mode

>>From 'emacs -Q', eval the following:

> (with-current-buffer (get-buffer-create "*test*")
>   (erase-buffer)
>   (insert "int main()\n{\n  \n}\n")
>   (search-backward "\n}")
>   (c-mode)
>   (save-restriction
>     (narrow-to-region (point) (point))
>     (insert "foo")))

> Gives the backtrace:

> Debugger entered--Lisp error: (args-out-of-range 1 1)
>   get-text-property(1 c-fl-syn-tab)
>   c-clear-string-fences()
>   #f(compiled-function () #<bytecode 0xbb39fd>)()
>   c-after-change(16 19 0)
>   insert("foo")
>   (save-restriction (narrow-to-region (point) (point)) (insert "foo"))
>   (save-current-buffer (set-buffer (get-buffer-create "*test*")) (erase-buffer) (insert "int main()\n{\n  \n}\n") (search-backward "\n}") (c-mode) (save-restriction (narrow-to-region (point) (point)) (insert "foo")))

Yes, thanks.  I've known about this for around a week, and I have a patch
for it prepared.  I was just giving the OP who reported it to me an extra
day or two to comment on it.

> This is a reduced test case from
> https://github.com/joaotavora/eglot/issues/291.

> I think the obvious fix is to extend the save-restriction just a bit
> further to cover c-clear-string-fences, patch attached.

Yes.  The "same" problem also happened in c-before-change, and my patch
fixes that, too.  (Otherwise, it's pretty much the same as your patch, as
far as c-after-change is concerned.)

I'll commit my patch soon, hopefully today.

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).





This bug report was last modified 6 years and 11 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.