GNU bug report logs - #28233
CC Mode 5.33 (C/*l); Emacs may get stuck with 100% CPU

Previous Next

Package: cc-mode;

Reported by: Mohammed Sadiq <sadiq <at> sadiqpk.org>

Date: Fri, 25 Aug 2017 15:32:01 UTC

Severity: normal

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Alan Mackenzie <acm <at> muc.de>
To: Mohammed Sadiq <sadiq <at> sadiqpk.org>
Cc: 28233 <at> debbugs.gnu.org
Subject: bug#28233: CC Mode 5.33 (C/*l); Emacs may get stuck with 100% CPU
Date: Sat, 26 Aug 2017 17:29:06 +0000
Hello, Mohammed.

On Fri, Aug 25, 2017 at 21:00:52 +0530, Mohammed Sadiq wrote:


> Emacs always get stuck when writing some code (given below), using 100 % CPU for
> (probably) limitless time:

> How to reproduce:

> 1. Open a new empty file: emacs -Q test.c
> 2. Write the following (| is where the point is)
>    #include<|
> 3. Delete the content: C-a C-k
> 4. Try to write the same again:
>    #include<|

> Result:
>   At the 4th step, after typing #,GNU Emacs begins to use full CPU and
>   does nothing. Though this can be cancelled using C-g.

Yes.  There is a bug in some cache handling code for macros, which
results in that cache thinking there's still a macro after it's been
deleted.

Thanks indeed for the bug report!

Would you please apply the following patch, then confirm to me that it's
fixed the problem, or else tell me what's still not working.  Thanks!



diff -r dbf1a31b3959 cc-engine.el
--- a/cc-engine.el	Tue Aug 22 16:38:44 2017 +0000
+++ b/cc-engine.el	Sat Aug 26 17:24:49 2017 +0000
@@ -250,7 +250,7 @@
   ;; Called from a before-change function.  If the change region is before or
   ;; in the macro characterized by `c-macro-cache' etc., nullify it
   ;; appropriately.  BEG and END are the standard before-change-functions
-  ;; parameters.  END isn't used.
+  ;; parameters.
   (cond
    ((null c-macro-cache))
    ((< beg (car c-macro-cache))
@@ -258,6 +258,12 @@
 	  c-macro-cache-start-pos nil
 	  c-macro-cache-syntactic nil
 	  c-macro-cache-no-comment nil))
+   ((and (= beg (car c-macro-cache))
+	 (> end beg))
+    (setq c-macro-cache nil
+	  c-macro-cache-start-pos nil
+	  c-macro-cache-syntactic nil
+	  c-macro-cache-no-comment nil))
    ((and (cdr c-macro-cache)
 	 (< beg (cdr c-macro-cache)))
     (setcdr c-macro-cache nil)


[ CC Mode configuration dump appreciated, but snipped. ]

-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 7 years and 348 days ago.

Previous Next


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