all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: pillowtrucker@proton.me
Cc: acm@muc.de, Eli Zaretskii <eliz@gnu.org>,
	Bob Weiner <rswgnu@gmail.com>,
	70423@debbugs.gnu.org
Subject: bug#70423: 29.3; cc-mode hang at 100% cpu and consuming all available memory
Date: Thu, 18 Apr 2024 18:39:53 +0000	[thread overview]
Message-ID: <ZiFo-eQsT0ieb5MD@ACM> (raw)
In-Reply-To: <z7Q1nYTrXe_VHXOqQOZtygzNa04b6oaz2Opi_swaV4eK5vvIwHF7KO-A02em-zjPqDqo5N_tm7jSJkqiug9gkT1qiTg1uFlAVcCfIg3dG2w=@proton.me>

Hello, Pillowtrucker!

On Tue, Apr 16, 2024 at 19:51:09 +0000, pillowtrucker@proton.me wrote:
> Greetings!

> I have been able to replicate a (relatively) minimum environment for
> this — hyperbole + clang-format.el.  I think lsp-mode aggravates the
> issue somehow, but is not necessary to enter the infinite loop. Without
> lsp-mode, however, the memory usage seems flat, as opposed to
> ballooning when it is present.  I would also guess that if you are able
> to plug in that regexp into cc-mode without installing all of
> hyperbole.el, you would probably get the same effect, but I didn't know
> how to do that. 


> You will need gzip and the clang-format utility for this from your
> linux distribution or compiled from source. Preferably version 18.1.3
> of the llvm suite, but it might work with earlier versions. I don't
> think /how/ it's formatting the file matters as much as the fact of it
> being altered to some degree.

OK.  I haven't actually evaluated your init.el (as I don't fully
understand it), but I have a strong hypothesis for the looping.

You're loading hyperbole as part of the initialisation.  This sets up the
value of defun-prompt-regexp to a ~760 character long string, whereas
normally in C++ Mode, this variable is nil.

This variable is what is seen in the second backtrace below, although it
is bowdlerised to a very short string ending in ... .  See the line below
emphasised with <=========================.

This regexp is known to be faulty, and sometimes to cause infinite
looping.  By coincidence, I have recently rewritten this regexp at the
request of Bob Weiner (in the Cc:), the maintainer of hyperbole, and he
is currently testing the regexp.  This faulty regexp may be the cause of
your bug, too.

So, could I ask you please to be patient, and wait for Bob to complete
his tests.  If they are successful, a new version of hyperbole is the
likely outcome, and this may solve your bug.

If there is any way you can run your test without installing the
hyperbole package, please do so, and let me know whether or not the hang
still occurs.

Thanks!

> Please follow these steps:
> 1. start with an empty directory
> $ export MYDEBUGDIR=emacs-debugging
> 2. use the attached init.el file as follows:
> $ emacs-29.3 --init-directory=${MYDEBUGDIR} -l init.el
> 3. Wait for the script to reach the point where it's in an infinite loop (check top/htop for emacs with 100% usage, maybe wait a few seconds or minutes to make sure it is not just taking a long time to run the formatting) and press C-g to send "quit".

> This results in a hang and the debugger should show something like this:

[ .... ]

> or maybe you will see:

> Debugger entered--Lisp error: (quit)
>   re-search-backward("^\\s(\\|\\(?:^[ \11]*\\(template\\s-*<[^>;.{}]+>\\s-*\\)?\\(..." nil move 1)  <==========================================================================
>   beginning-of-defun-raw(nil)
>   beginning-of-defun()
>   c-get-fallback-scan-pos(18908)
>   c-parse-state-get-strategy(18908 1)
>   c-parse-state-1()
>   c-parse-state()
>   c-laomib-invalidate-cache(18908 18910)
>   c-before-change(18908 18910)
>   clang-format--replace(18908 2 "\n")
>   apply(clang-format--replace (18908 2 "\n"))
>   clang-format-region(1 18910 nil nil)
>   clang-format-buffer()
>   load-with-code-conversion("/home/wrath/emacs-debugging2/init.el" "/home/wrath/emacs-debugging2/init.el" nil t)
>   command-line-1(("-l" "emacs-debugging2/init.el"))
>   command-line()
>   normal-top-level()

> Either way it does seem like the problem lies somewhere in cc-mode
> choking either on the file itself or on that regular expression.

> I license the attached init.el under the terms of the AGPL-3 or later
> version. The drm_formats.cpp file is part of the MIR Server project and
> is licensed under the terms of the GPL-v3. Both licenses attached. I'm
> not sure if I am allowed to re-license the MIR file as AGPL, but I
> believe they are in any case compatible to be distributed together.

> Thank you for having a look at this issue, it has been plaguing me
> since november and even making rust look like an ever so slightly more
> pleasant alternative to dealing with constant hangs/crashes and having
> to restore frame/window layouts when editing C/C++..

> Kind regards,
> M.

-- 
Alan Mackenzie (Nuremberg, Germany).





  reply	other threads:[~2024-04-18 18:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 13:36 bug#70423: 29.3; cc-mode hang at 100% cpu and consuming all available memory 1stmil.eth via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-16 15:52 ` bug#70423: Possible workaround/culprit pillowtrucker--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-16 18:31   ` Dmitry Gutov
2024-04-16 16:22 ` bug#70423: 29.3; cc-mode hang at 100% cpu and consuming all available memory Eli Zaretskii
2024-04-16 17:05   ` Alan Mackenzie
2024-04-16 17:59 ` Alan Mackenzie
2024-04-16 19:51   ` pillowtrucker--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-18 18:39     ` Alan Mackenzie [this message]
2024-04-19 20:49       ` pillowtrucker--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-20  9:22         ` Alan Mackenzie
2024-04-20 13:14           ` Robert Weiner
2024-04-20 15:52             ` Robert Weiner
2024-05-02  8:40               ` Eli Zaretskii
2024-05-02 22:01                 ` Robert Weiner
2024-05-03  5:54                   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZiFo-eQsT0ieb5MD@ACM \
    --to=acm@muc.de \
    --cc=70423@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=pillowtrucker@proton.me \
    --cc=rswgnu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.