GNU bug report logs - #57804
An infinite loop in a `fontify-region' function causes Emacs to hang indefinitely

Previous Next

Package: emacs;

Reported by: Paul Pogonyshev <pogonyshev <at> gmail.com>

Date: Wed, 14 Sep 2022 15:07:01 UTC

Severity: normal

Tags: wontfix

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Gregory Heytings <gregory <at> heytings.org>
To: Paul Pogonyshev <pogonyshev <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 57804 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org>
Subject: bug#57804: An infinite loop in a `fontify-region' function causes Emacs to hang indefinitely
Date: Thu, 15 Sep 2022 20:18:27 +0000
[Message part 1 (text/plain, inline)]
>
> I see that manually evaluating `(setq-local long-line-threshold nil)' in 
> a buffer where the optimization is already in effect (i.e. where 
> `(long-line-optimizations-p)' evaluates to t) doesn't disable the 
> optimization. Do you have a solution for that?
>

No, and that will not be supported.

>
> Depending on the mode being activated before Emacs decides to enable the 
> optimization (e.g. because one of the first lines is very long, I don't 
> know how exactly this is determined) seems very shaky.
>

Indeed.  As I told you the proper fix is not to disable these 
optimizations, but to adapt the code to handle locked narrowing, by 
explicitly unlocking the locked narrowing when, and only when, it needs to 
access a larger portion of the buffer.

>
> I briefly looked at the branch `feature/improved-narrowed-locking' and 
> saw that locking grew "tags". This probably implies that this is going 
> to be used more in the future, maybe already in Emacs 29.1. Is there 
> going to be some way to disable each and every new tag? Should I monitor 
> Emacs sources for new cases of narrowed locking with a tag previously 
> not used?
>

No, if your function is called inside fontification-functions, you will 
not have to monitor Emacs sources, your code will use a single tag, namely 
'fontification-functions.

>
> What if one day this becomes available to Elisp and a submode that 
> decides to narrow-lock for whatever reason?
>

Don't worry, that won't happen.

>
> Wouldn't something like
> 
> (let ((disable-locked-narrowing-yes-i-know-this-is-bad-but-still t))
>    (widen)
>    ...
> )
>
> not be much more robust?
>

Definitely not.  It is more important to take measures to ensure that 
Emacs remains responsive for its users than to minimize the effort of 
Elisp programmers.

This bug report was last modified 2 years and 230 days ago.

Previous Next


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