GNU bug report logs - #16585
c-invalidate-state-cache fails if called when narrowed

Previous Next

Packages: emacs, cc-mode;

Reported by: Daniel Colascione <dancol <at> dancol.org>

Date: Wed, 29 Jan 2014 02:10:01 UTC

Severity: normal

Done: Daniel Colascione <dancol <at> dancol.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Daniel Colascione <dancol <at> dancol.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#16585: closed (c-invalidate-state-cache fails if called when
 narrowed)
Date: Sun, 16 Feb 2014 02:56:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sat, 15 Feb 2014 18:55:00 -0800
with message-id <53002884.1030103 <at> dancol.org>
and subject line Re: [Emacs-diffs] trunk r116378: Fix c-invalidate-state-cache on narrowed buffers.
has caused the debbugs.gnu.org bug report #16585,
regarding c-invalidate-state-cache fails if called when narrowed
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
16585: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16585
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Daniel Colascione <dancol <at> dancol.org>
To: bug-emacs <bug-gnu-emacs <at> gnu.org>
Cc: Alan Mackenzie <acm <at> muc.de>
Subject: c-invalidate-state-cache fails if called when narrowed
Date: Tue, 28 Jan 2014 18:09:04 -0800
c-invalidate-state-cache can fail if called in a narrowed region: we end 
up calling c-clear-char-property for bob even if that's before 
point-min, causing remote-text-properties to raise (args-out-of-range 1 2).

We get into this situation when expanding yasnippet snippets; we're 
calling c-invalidate-state-cache from c-before-change.

To repro manually, first write this to some buffer.

#include <stdio.h>

void foo() {

}


Then (this is important) run M-x c-mode. After starting the mode, move 
point to inside foo's body and eval (save-restriction (narrow-to-region 
(point-at-bol) (point-at-eol)) (c-invalidate-state-cache (point))). You 
should break into the debugger.

The patch below seems correct and fixes the problem for me, but it'd be 
nice if Alan could take a look at it before I push it to trunk. The 
version of c-invalidate-state-cache in cc-mode trunk is very different.

=== modified file 'lisp/progmodes/cc-engine.el'
--- lisp/progmodes/cc-engine.el	2014-01-19 12:32:47 +0000
+++ lisp/progmodes/cc-engine.el	2014-01-29 02:07:44 +0000
@@ -3318,15 +3318,17 @@
   ;; of all parens in preprocessor constructs, except for any such 
construct
   ;; containing point.  We can then call `c-invalidate-state-cache-1' 
without
   ;; worrying further about macros and template delimiters.
-  (c-with-<->-as-parens-suppressed
-   (if (and c-state-old-cpp-beg
-	    (< c-state-old-cpp-beg here))
-       (c-with-all-but-one-cpps-commented-out
-	c-state-old-cpp-beg
-	(min c-state-old-cpp-end here)
-	(c-invalidate-state-cache-1 here))
-     (c-with-cpps-commented-out
-      (c-invalidate-state-cache-1 here)))))
+  (save-restriction
+    (widen)
+    (c-with-<->-as-parens-suppressed
+     (if (and c-state-old-cpp-beg
+              (< c-state-old-cpp-beg here))
+         (c-with-all-but-one-cpps-commented-out
+          c-state-old-cpp-beg
+          (min c-state-old-cpp-end here)
+          (c-invalidate-state-cache-1 here))
+       (c-with-cpps-commented-out
+        (c-invalidate-state-cache-1 here))))))

 (defmacro c-state-maybe-marker (place marker)
   ;; If PLACE is non-nil, return a marker marking it, otherwise nil.



[Message part 3 (message/rfc822, inline)]
From: Daniel Colascione <dancol <at> dancol.org>
To: Alan Mackenzie <acm <at> muc.de>, emacs-devel <at> gnu.org, 
 16585-done <at> debbugs.gnu.org
Subject: Re: [Emacs-diffs] trunk r116378: Fix c-invalidate-state-cache on
 narrowed buffers.
Date: Sat, 15 Feb 2014 18:55:00 -0800
Thanks. Seems fixed now.

On 02/09/2014 04:38 AM, Alan Mackenzie wrote:
> ------------------------------------------------------------
> revno: 116378
> revision-id: acm <at> muc.de-20140209123425-ms311yngryt01jls
> parent: rgm <at> gnu.org-20140209112300-kf0j1tnx3rj0efyn
> committer: Alan Mackenzie <acm <at> muc.de>
> branch nick: trunk
> timestamp: Sun 2014-02-09 12:34:25 +0000
> message:
>    Fix c-invalidate-state-cache on narrowed buffers.
>    progmodes/cc-defs.el (c-with-all-but-one-cpps-commented-out): Widen when
>    setting and clearing the CPP delimiter properties.
> modified:
>    lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
>    lisp/progmodes/cc-defs.el      ccdefs.el-20091113204419-o5vbwnq5f7feedwu-1226
>
>
>
> _______________________________________________
> Emacs-diffs mailing list
> Emacs-diffs <at> gnu.org
> https://lists.gnu.org/mailman/listinfo/emacs-diffs
>


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

Previous Next


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