all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: "1stmil.eth" <1stmil.eth@proton.me>
Cc: acm@muc.de, Eli Zaretskii <eliz@gnu.org>, 70423@debbugs.gnu.org
Subject: bug#70423: 29.3; cc-mode hang at 100% cpu and consuming all available memory
Date: Tue, 16 Apr 2024 17:59:54 +0000	[thread overview]
Message-ID: <Zh68mmCE_P62A5kO@ACM> (raw)
In-Reply-To: <L7i6g9YVxKuh4RwVYt4oxcVxfNpEmqjvXfoci8RU7VqxDkCfI7Vq0Vb2q3ttYE4rnropLQwVvfyqB94C6fhCe-jKtT9CC4wxvrGQhbXxJGo=@proton.me>

Hello.

Thanks for taking the trouble to submit this bug report.

On Tue, Apr 16, 2024 at 13:36:16 +0000, 1stmil.eth wrote:
> Among other scenarios, when clang-format runs as a hook on file save
> when I make any (even noop) edit in
> https://github.com/pillowtrucker/mir/blob/main/src/platform/graphics/drm_formats.cpp
> this file, for example, emacs enters an infinite loop consuming 100%
> of a cpu core and all memory up to gc threshold.

> It is not always the regex function on the top of the stack but it is always a call around those functions
> "beginning-of-defun-raw"
> "beginning-of-defun"
> "c-get-fallback-scan-pos"
> (gdb) bt full

Yes.  c-parse-state is known for sometimes looping - it is an awkward
spot where doing something rigorusly is likely to be (far) too slow, but
the ad hoc speed ups occasionally go wrong.  That seems to be the
problem here.

[ The gdb backtrace (snipped) unfortunately isn't very helpful, here. ]

> Inside of emacs I get something like this:

> Debugger entered--Lisp error: (quit)  re-search-backward("^\\s(\\|\\(?:^[ \11]*\\(template\\s-*<[^>;.{}]+>\\s-*\\)?\\(\\(\\(auto\\|const\\|explicit\\|extern\\s-+\"[^\"]+\"\\|extern\\|friend\\|inline\\|mutable\\|overload\\|register\\|static\\|typedef\\|virtual\\)\\s-+\\)*\\(\\([[<a-zA-Z][]_a-zA-Z0-9]*\\(::[]_a-zA-Z0-9]+\\)?\\s-*<[_<>a-zA-Z0-9 ,]+>\\s-*[*&]*\\|[[<a-zA-Z][]_<>a-zA-Z0-9]*\\(::[[<a-zA-Z][]_<>a-zA-Z0-9]+\\)?\\s-*[*&]*\\)[*& \11\n\15]+\\)\\)?\\(\\(::\\|[[<a-zA-Z][]_a-zA-Z0-9]*\\s-*<[^>;{}]+>\\s-*[*&]*::\\|[[<a-zA-Z][]_~<>a-zA-Z0-9]*\\s-*[*&]*::\\)\\s-*\\)?\\(operator\\s-*[^ \11\n\15:;.,?~{}]+\\(\\s-*\\[\\]\\)?\\|[_~<a-zA-Z][^][ \11:;.,~{}()\177]*\\|[*&]?\\([_~<a-zA-Z][_a-zA-Z0-9]*\\s-*<[^>;{}]+[ \11\n\15>]*>\\|[_~<a-zA-Z][_~<>a-zA-Z0-9]*\\)\\)\\s-*\\(([^{;]*)\\(\\(\\s-+const\\|
 \\s-+mutable\\)?\\(\\s-*[=:][^;{]+\\)?\\)?\\)\\s-*\\)\\s(" nil move 1)
>   beginning-of-defun-raw(nil)
>   beginning-of-defun()
>   c-get-fallback-scan-pos(18875)
>   c-parse-state-get-strategy(18875 13474)
>   c-parse-state-1()
>   c-parse-state()
>   c-laomib-invalidate-cache(18875 18880)
>   c-before-change(18875 18880)

The functions thus far suggest that your file is somewhat unusual; it
has, perhaps, long stretches of text without braces, or long brace
blocks.

Could you possibly send me a copy of the above C++ file, or point me to
an open website (not github) where I could download a copy?  I have no
access to github, since I am not prepared to let probably hostile
scripts controlled by Microsoft run on my machine.

>   lsp--apply-text-edit-replace-buffer-contents(#<hash-table equal 2/2 0x120ad92d>)
>   #f(compiled-function (edit) #<bytecode -0x9b8e84b9515e2ea>)(#<hash-table equal 2/2 0x120ad92d>)
>   lsp--apply-text-edits((#<hash-table equal 2/2 0x12062b03>) format)
>   lsp-format-buffer()
>   run-hooks(before-save-hook)
>   basic-save-buffer(t)
>   save-buffer(1)
>   funcall-interactively(save-buffer 1)
>   #<subr call-interactively>(save-buffer nil nil)
>   call-interactively@ido-cr+-record-current-command(#<subr call-interactively> save-buffer nil nil)
>   apply(call-interactively@ido-cr+-record-current-command #<subr call-interactively> (save-buffer nil nil))
>   call-interactively(save-buffer nil nil)
>   command-execute(save-buffer)

> This is not the only scenario when this happens. I can also sometimes
> trigger the same thing by trying to jump to the definition of a symbol
> from a .cpp/c++-header file into a system header (all of which are on
> a read-only filesystem on my computer), for example one of the SDL
> headers. The main difference is that the buffer-switching gets mixed
> into the lot and emacs doesn't even respond to C-g and I have to kill
> -SIGUSR2 it to get it to start responding again, but I'm pretty sure
> it's the same bug - output from this scenario is here:
> https://0x0.st/X-RT.txt

What would be most helpful here would be a reliable recipe to reproduce
the bug without needing other libraries such as lsp, preferably starting
from emacs -Q.

> I'm sorry about the <optimized out> everywhere and lack of inlined
> sources, but I've already rebuilt it with nixos's enableDebugging
> flag, which should have enabled -Og and -g3 (I think it did do the
> latter but failed on the optimizations and left it at O2) and I've
> already spent most of my day debugging this and it would take another
> full day to figure out how to properly override the byzantine nixpkgs
> emacs infrastructure with the right optimization flag and to store the
> right source tree.

Yes, bugs are like that sometimes.  I'm afraid I don't know anything
about nixos.

> In GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
> version 1.18.0, Xaw3d scroll bars)
> Windowing system distributor 'The X.Org Foundation', version 11.0.12101012
> System Description: NixOS 24.05 (Uakari)

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).






  parent reply	other threads:[~2024-04-16 17:59 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 [this message]
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
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=Zh68mmCE_P62A5kO@ACM \
    --to=acm@muc.de \
    --cc=1stmil.eth@proton.me \
    --cc=70423@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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.