From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs 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 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10920"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, Eli Zaretskii , 70423@debbugs.gnu.org To: "1stmil.eth" <1stmil.eth@proton.me> Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 16 20:01:20 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rwn7Q-0002eh-Ez for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Apr 2024 20:01:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwn71-0007ku-3C; Tue, 16 Apr 2024 14:00:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwn6x-0007kJ-Ed for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2024 14:00:52 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rwn6x-0003br-5z for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2024 14:00:51 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rwn79-0000KS-7Y for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2024 14:01:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Apr 2024 18:01:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70423 X-GNU-PR-Package: emacs Original-Received: via spool by 70423-submit@debbugs.gnu.org id=B70423.1713290425897 (code B ref 70423); Tue, 16 Apr 2024 18:01:03 +0000 Original-Received: (at 70423) by debbugs.gnu.org; 16 Apr 2024 18:00:25 +0000 Original-Received: from localhost ([127.0.0.1]:44965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwn6U-0000Dq-7m for submit@debbugs.gnu.org; Tue, 16 Apr 2024 14:00:24 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:51260) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwn6P-0000CZ-Js for 70423@debbugs.gnu.org; Tue, 16 Apr 2024 14:00:21 -0400 Original-Received: (qmail 52885 invoked by uid 3782); 16 Apr 2024 19:59:59 +0200 Original-Received: from muc.de (p4fe15f24.dip0.t-ipconnect.de [79.225.95.36]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 16 Apr 2024 19:59:59 +0200 Original-Received: (qmail 11542 invoked by uid 1000); 16 Apr 2024 17:59:54 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283452 Archived-At: 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-Z0-9 ,]+>\\s-*[*&]*\\|[[a-zA-Z0-9]*\\(::[[a-zA-Z0-9]+\\)?\\s-*[*&]*\\)[*& \11\n\15]+\\)\\)?\\(\\(::\\|[[;{}]+>\\s-*[*&]*::\\|[[a-zA-Z0-9]*\\s-*[*&]*::\\)\\s-*\\)?\\(operator\\s-*[^ \11\n\15:;.,?~{}]+\\(\\s-*\\[\\]\\)?\\|[_~;{}]+[ \11\n\15>]*>\\|[_~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(#) >   #f(compiled-function (edit) #)(#) >   lsp--apply-text-edits((#) format) >   lsp-format-buffer() >   run-hooks(before-save-hook) >   basic-save-buffer(t) >   save-buffer(1) >   funcall-interactively(save-buffer 1) >   #(save-buffer nil nil) >   call-interactively@ido-cr+-record-current-command(# save-buffer nil nil) >   apply(call-interactively@ido-cr+-record-current-command # (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 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).