GNU bug report logs - #18696
Emacs freezes for a while visitin Conf (.ini)) buffers

Previous Next

Package: emacs;

Reported by: Angelo Graziosi <angelo.graziosi <at> alice.it>

Date: Sun, 12 Oct 2014 08:25:02 UTC

Severity: normal

Tags: moreinfo

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 18696 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 18696 <at> debbugs.gnu.org,
 Angelo Graziosi <angelo.graziosi <at> alice.it>
Subject: Re: bug#18696: Emacs freezes for a while visitin Conf (.ini)) buffers
Date: Thu, 19 Aug 2021 16:55:12 +0200
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:

> Actually IIUC which-function-mode shouldn't cause such a slow down.
> If it does, it's probably because the major mode doesn't have special
> support for which-function-mode, so it falls back on using imenu's
> support, i.e. it needs to scan the whole buffer.
>
> This said, scanning the whole buffer shouldn't be that sow, unless you
> really have very many sections.  So it might also simply be a bug in the
> way the major mode supports imenu (e.g. the regexp used is inefficient).

I can reproduce this problem in Emacs 28:

curl https://mirrors.kernel.org/sourceware/cygwin/x86_64/setup.ini > /tmp/setup.ini
./src/emacs -f which-function-mode -Q /tmp/setup.ini
y

Emacs hangs completely, and even `C-g' doesn't help.

The major mode here is conf-colon-mode, which does:

  (setq-local imenu-generic-expression
	      `(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*:" 1)
	        ,@(cdr imenu-generic-expression))))

And, indeed, removing that make the file open in a couple of seconds
instead of taking forever (where "forever" is defined as "longer than I
had patience to wait").

Hm...  That regexp does have some backtracking in it, but this is
an 18MB file where 99.997% of the lines match the regexp:

sdesc: "Debug info for 2048-cli"
ldesc: "This package contains files necessary for debugging the
2048-cli package with gdb."
category: Debug
requires: cygwin-debuginfo
version: 0.9.1-1

etc.

So no matter how efficient the regexp is, it's gonna hang here.

Perhaps `imenu-default-create-index-function' should just give up after
spending more than x seconds?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 3 years and 303 days ago.

Previous Next


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