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: Paul Pogonyshev <pogonyshev <at> gmail.com>
To: Gregory Heytings <gregory <at> heytings.org>
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 23:49:10 +0200
[Message part 1 (text/plain, inline)]
> It can do so (or more precisely will be able to do so) by calling
> narrowing-unlock with the appropriate tag, which IIUC correctly is, in
> your case, 'fontification-functions.

OK, let me rewrite this in a bit more details. Here are some quotes
from the C code in the branch:

    safe_run_hooks_maybe_narrowed (Qpre_command_hook,
                                   XWINDOW (selected_window));

    ...

    safe_run_hooks_maybe_narrowed (Lisp_Object hook, struct window *w)
    {
      ...
      if (current_buffer->long_line_optimizations_p)
        narrow_to_region_locked (make_fixnum (get_narrowed_begv (w, PT)),
                                 make_fixnum (get_narrowed_zv (w, PT)),
                                 hook);

Note how `hook' becomes `tag', i.e. narrowing is locked with tag
`pre-command-hook' _in this case_. According to the code, it can also
be locked with a few others, e.g. `post-command-hook'.

Now, user writes in his `init.el' sth. like:

    (add-hook 'pre-command-hook (lambda ()
                                  (when (eq major-mode 'logview-mode)
                                    (logview-do-bla-bla-bla))))

I don't know why, this is a hypothetical, but fairly realistic
situation, right?

Now, let's say function `logview-do-bla-bla-bla' cannot work with
narrowed buffer (half of functions in Logview cannot).  So, as a first
step it does something like this:

    (save-restriction
      (widen)
      ...
      )

For this to keep working in Emacs 29, I will need to replace `(widen)'
with I-don't-yet-know-what.  But _I don't know the tag_.  That's the
problem.  The function is called from somewhere I have no control, it
can be bound to any hook that does install locked narrowing with some
tag or maybe does not - I have no way to know that.

Will I be able to lift locked narrowing restrictions without knowing
the tag?

Paul

On Thu, 15 Sept 2022 at 23:32, Gregory Heytings <gregory <at> heytings.org>
wrote:

>
> >
> > Logview needs to temporarily cancel restrictions in _practically all_
> > its function.
> >
>
> It can do so (or more precisely will be able to do so) by calling
> narrowing-unlock with the appropriate tag, which IIUC correctly is, in
> your case, 'fontification-functions.  I don't see why you would need
> anything else, especially given that a general mechanism to disable locked
> narrowing everywhere is already available for users who, like you, don't
> care about long lines.
>
[Message part 2 (text/html, inline)]

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.