From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Paul Pogonyshev Newsgroups: gmane.emacs.bugs Subject: bug#57804: An infinite loop in a `fontify-region' function causes Emacs to hang indefinitely Date: Thu, 15 Sep 2022 23:17:25 +0200 Message-ID: References: <87pmfx6h7y.fsf@gnus.org> <2b58b8f5429a6e3aecda@heytings.org> <834jx85tyv.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000537e8205e8bdc6ae" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18915"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 57804@debbugs.gnu.org, Lars Ingebrigtsen To: Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 15 23:18:56 2022 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 1oYwG8-0004hk-LW for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 15 Sep 2022 23:18:56 +0200 Original-Received: from localhost ([::1]:45788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oYwG7-0006ro-H5 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 15 Sep 2022 17:18:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oYwFH-0006TQ-0J for bug-gnu-emacs@gnu.org; Thu, 15 Sep 2022 17:18:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42443) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oYwFG-0007Js-FQ for bug-gnu-emacs@gnu.org; Thu, 15 Sep 2022 17:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oYwFG-000812-4A for bug-gnu-emacs@gnu.org; Thu, 15 Sep 2022 17:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Pogonyshev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Sep 2022 21:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57804 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: wontfix Original-Received: via spool by 57804-submit@debbugs.gnu.org id=B57804.166327667230796 (code B ref 57804); Thu, 15 Sep 2022 21:18:02 +0000 Original-Received: (at 57804) by debbugs.gnu.org; 15 Sep 2022 21:17:52 +0000 Original-Received: from localhost ([127.0.0.1]:59375 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oYwF3-00080b-Ak for submit@debbugs.gnu.org; Thu, 15 Sep 2022 17:17:52 -0400 Original-Received: from mail-ej1-f47.google.com ([209.85.218.47]:38691) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oYwEx-00080H-AS for 57804@debbugs.gnu.org; Thu, 15 Sep 2022 17:17:47 -0400 Original-Received: by mail-ej1-f47.google.com with SMTP id u9so45038704ejy.5 for <57804@debbugs.gnu.org>; Thu, 15 Sep 2022 14:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=NXRqV0LglmB4u37m0OZX2azEp7WoJfkKPjU4xgeC65M=; b=Q7XmrZOHEyVGEieMDzmgLRYRpp/nP1Lq8RzXulNKh6xLh5rj6Q4QiTWkCZOeOk77gp EGfw2M7v+zVxNHtgfy5T5IQ32vFNlpUtCLCn1hr+0qq8Jiuk5sRNLnqvgxsoIvszBlhQ brmB3jQH1Co1d8C7wgdOkE4xeejB3hYjQxClNfEimGD4avN95KgYcIrgevc1FWJtWQCT uQw3gnQ4Ifhn2UWJwlNUXBA/rY7sgdBNEzkBjkVwPqzqJgvwRsEo1r4u44LbEYsyOn48 ef0L34hkFJtJe7NrL511otch6tKgxJwj65hyZRa10KI8Ix0N116052Ves5OJAfIPmPWd 6Ykw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=NXRqV0LglmB4u37m0OZX2azEp7WoJfkKPjU4xgeC65M=; b=JJYh6XZW47ne26eBo2fKFGRL73sKj1Ta5n1p+ucfe7kzhl3CUSfcY/ubijZiS7XuKo TqshIt/KT9Kq2CRV+5rFgDed2WGRMk4rVbdceuel97I/Cb/QKuFc5GUwxEYX8uvhiRBj t5DUV0NT9peAinKfncuiwVnxdoFu6pYa/PPHUGKu4Fi2FzNQ8qfg7OlkOcL1/CRLrA2/ lh2As/3KF+9COsrzGOJzJTjvTI9gIS2WZkqZTf/h1qSn9b0Q9D73Y/t12xIQQm94NIvN LddlqV+QPAQPF14+RbG+egydjd4tLQtZbd+y+dfKrnYE1yV5Z+rCk2OhGZuJc09T3R8r NlOQ== X-Gm-Message-State: ACrzQf0jGZj2ldNX3C6kG7xBBd0yF4sts8GCGl4WiftLZc294rjqv+87 N+IUf05acU+vKjViPnb75UTvg8apXrHIOhRRMg== X-Google-Smtp-Source: AMsMyM7isLQXacK7u/dq6kfVd/QdO0oRKlk0FiC06GWDIs1IqGR9PKrAqnep5pYJkJaCee9ewASj3H2FayAAgMEhJDg= X-Received: by 2002:a17:906:fe09:b0:77a:52b3:da5d with SMTP id wy9-20020a170906fe0900b0077a52b3da5dmr1239077ejb.57.1663276657375; Thu, 15 Sep 2022 14:17:37 -0700 (PDT) In-Reply-To: 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" Xref: news.gmane.io gmane.emacs.bugs:242651 Archived-At: --000000000000537e8205e8bdc6ae Content-Type: text/plain; charset="UTF-8" >>> 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. >> >> So, I will be able to unlock? > > Yes. Good. > > Wouldn't something like [...] not be much more robust? > > Definitely not. But why? If you allow to lift restrictions, why not make it easy to do? Call the variable/function that achieves this with a 100-character name, brand the programmer an idiot in the name or documentation - whatever. Don't advertise it in the manual, maybe add two lines somewhere in a dark corner, repeating that only morons would use it. But please, add something generic and simple to use. Logview needs to temporarily cancel restrictions in _practically all_ its function. In the branch I see code like this: narrow_to_region_locked (make_fixnum (get_narrowed_begv (w, PT)), make_fixnum (get_narrowed_zv (w, PT)), hook); ^^^^ So, suppose something in that hook (maybe even not installed by Logview itself, e.g. by a minor mode or by the user: it is common to have `add-hook' in Emacs initialization code) calls a function from Logview. Now, that function from Logview does (please-widen-i-cant-work-with-locked-narrowing ...) It, presumably, cannot know the tag used to install locked narrowing. Will it be able to temporarily lift _any and all_ locked narrowing or not? It probably won't freeze Emacs even if falling into an infinite loop, likely there are not so many non-bugs like the one in this thread, where misbehaving code can make Emacs hang irrepairably. But still, if restrictions are not lifted, Logview function will likely produce some incorrect result, require C-g to abort, or die with an error. Will the knowledge of the tag be required, as a sort of a "password", to lift narrowing restrictions, or not? Paul On Thu, 15 Sept 2022 at 22:44, Gregory Heytings wrote: > > >> 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. > > > > So, I will be able to unlock? > > > > Yes. > > > > > Let Logview behave against your recommendations. And then, when the > > users discover how crappy and unresponsive it is, as a result, compared > > to everything else, they will just uninstall the package and use > > something better. > > > > Given that you will be able to unlock, that will be possible. > --000000000000537e8205e8bdc6ae Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
>>> No, if your function is call= ed inside fontification-functions, you will
>>> not have to mon= itor Emacs sources, your code will use a single tag,
>>> namely= 'fontification-functions.
>>
>> So, I will be able t= o unlock?
>
> Yes.

Good.

> > Wouldn't s= omething like [...] not be much more robust?
>
> Definitely not= .

But why? If you allow to lift restrictions, why not make it easy t= o
do? Call the variable/function that achieves this with a 100-character=
name, brand the programmer an idiot in the name or documentation -
w= hatever. Don't advertise it in the manual, maybe add two lines
somew= here in a dark corner, repeating that only morons would use
it. But plea= se, add something generic and simple to use.

Logview needs to tempor= arily cancel restrictions in _practically all_
its function. In the bran= ch I see code like this:

=C2=A0 =C2=A0 narrow_to_region_locked (make= _fixnum (get_narrowed_begv (w, PT)),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0make_f= ixnum (get_narrowed_zv (w, PT)),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0hook);=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^^^^

So, suppo= se something in that hook (maybe even not installed by
Logview itself, e= .g. by a minor mode or by the user: it is common to
have `add-hook' = in Emacs initialization code) calls a function from
Logview. Now, that f= unction from Logview does

=C2=A0 =C2=A0 (please-widen-i-cant-work-wi= th-locked-narrowing ...)

It, presumably, cannot know the tag used to= install locked narrowing.
Will it be able to temporarily lift _any and = all_ locked narrowing or
not? It probably won't freeze Emacs even if= falling into an infinite
loop, likely there are not so many non-bugs li= ke the one in this
thread, where misbehaving code can make Emacs hang ir= repairably. But
still, if restrictions are not lifted, Logview function = will likely
produce some incorrect result, require C-g to abort, or die = with an
error.

Will the knowledge of the t= ag be required, as a sort of a "password",
to lift narrowing r= estrictions, or not?

Paul

On Thu, 15 Sept = 2022 at 22:44, Gregory Heytings <gregory@heytings.org> wrote:

>> 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.
>
> So, I will be able to unlock?
>

Yes.

>
> Let Logview behave against your recommendations. And then, when the > users discover how crappy and unresponsive it is, as a result, compare= d
> to everything else, they will just uninstall the package and use
> something better.
>

Given that you will be able to unlock, that will be possible.
--000000000000537e8205e8bdc6ae--