bug#55771: [Michael Welsh Duggan] bug#55771: 29.0.50; cc-mode based uninterruptible infloop

Alan Mackenzie <[email protected]> Tue, 7 Jun 2022 20:45:02 +0000
Newsgroups gmane.emacs.cc-mode.general
Message-ID <Yp+4zs25sxDgBTIA@ACM>
Hello, Michael.

On Mon, Jun 06, 2022 at 23:41:05 -0400, Michael Welsh Duggan wrote:
> I just wanted to poke you on this one, as I'm not certain it entered
> your notice due to the shoddy way I submitted it.

Apologies.  I missed it.

[ .... ]

> -------------------- Start of forwarded message --------------------
> Subject: bug#55771: 29.0.50; cc-mode based uninterruptible infloop
> To: [email protected]
> From: Michael Welsh Duggan <[email protected]>
> Date: Thu, 02 Jun 2022 14:26:08 -0400


> Create a directory containing the following two files:

> .dir-locals.el



> bug.el

> #ifndef IPFIX_FLOATPOINT_HPP
> #define IPFIX_FLOATPOINT_HPP
> 
> IPFIX__NEW_NAMESPACE
> 
> #endif  // IPFIX_FLOATPOINT_HPP


> >From that directory, run "emacs -Q bug.hpp".

> The result is an inflooping emacs from which `C-g' and `ESC ESC ESC'
> seem to do nothing useful.

> I stopped it in the debugger and ran `fin' several times, interspersing
> with `xbacktrace' calls until `fin` did not return.  The result is
> copied herein:

[ .... ]

Thanks, that backtrace was extraordinarily helpful.  It was one of these
places where I'd neglected to test the return code of c-forward-token-2.
As a result, point stayed in the same place in a loop which thus became
an infinite loop.

Can I ask you, please, to try out the following patch, and let me know
if it fixes the bug in your real C++ code.

I don't want to commit this yet, since I haven't yet checked CC Mode for
the same bug somewhere else (and it's getting late, here).  I may not
have much time to look at this in the next few days.



diff -r 6057991425e3 cc-engine.el
--- a/cc-engine.el	Tue May 24 16:11:52 2022 +0000
+++ b/cc-engine.el	Tue Jun 07 20:33:41 2022 +0000
@@ -8312,9 +8312,10 @@
 (defun c-forward-noise-clause ()
   ;; Point is at a c-noise-macro-with-parens-names macro identifier.  Go
   ;; forward over this name, any parenthesis expression which follows it, and
-  ;; any syntactic WS, ending up at the next token.  If there is an unbalanced
-  ;; paren expression, leave point at it.  Always Return t.
-  (c-forward-token-2)
+  ;; any syntactic WS, ending up at the next token or EOB.  If there is an
+  ;; unbalanced paren expression, leave point at it.  Always Return t.
+  (or (zerop (c-forward-token-2))
+      (goto-char (point-max)))
   (if (and (eq (char-after) ?\()
 	   (c-go-list-forward))
       (c-forward-syntactic-ws))



> In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0)
>  of 2022-06-02 built on miko
> Repository revision: 8f279c8666dc642ed1f8f49aa709530fcea47374
> Repository branch: master
> Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
> System Description: Debian GNU/Linux bookworm/sid

> Configured using:
>  'configure --without-toolkit-scroll-bars --with-x-toolkit=lucid
>  --with-native-compilation --with-xinput2 'CFLAGS=-Og -ggdb''

[ .... ]

> -- 
> Michael Welsh Duggan
> ([email protected])

-- 
Alan Mackenzie (Nuremberg, Germany).