GNU bug report logs - #41441
26.3; mhtml misbehaving font-lock extend region can cause Emacs to hang

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Anders Lindgren <andlind@HIDDEN>; dated Thu, 21 May 2020 20:15:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 41441 <at> debbugs.gnu.org:


Received: (at 41441) by debbugs.gnu.org; 27 May 2020 21:32:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed May 27 17:32:25 2020
Received: from localhost ([127.0.0.1]:50174 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1je3ez-0008Cr-FW
	for submit <at> debbugs.gnu.org; Wed, 27 May 2020 17:32:25 -0400
Received: from mail-wm1-f47.google.com ([209.85.128.47]:53548)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1je3ex-00088h-5b
 for 41441 <at> debbugs.gnu.org; Wed, 27 May 2020 17:32:23 -0400
Received: by mail-wm1-f47.google.com with SMTP id l26so1062940wme.3
 for <41441 <at> debbugs.gnu.org>; Wed, 27 May 2020 14:32:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=zi2f0mEfeTshxpFhqTOwWHvx3Bq7GLRDnAfDtleubxQ=;
 b=XVI14kwXaEb2one74jF2tJl3PLQ9Lkbx7feu9WsT8mw/Iul2c4ro4jcQ/+/fcb0mw5
 xU53cuvCab0nX/RwBR9BPC0aQ2E4RYFyxwxT7JkEvurKmAixQuagCyAa/bHxSkYlMvO8
 n3fhYijpyCQuik9KueayTpVMxOOG2yb5N2tBJokcifmSAkB90rZsVL6ARas/wjngiyzV
 syqq8N5h5Ys9CUc2lGElXVqlyUzbTY5a7gjIOQG/AazQ1ewyFWC41s8RStGFPeqHtm55
 k6TCl5LjciKYLpZM2dS3eTWynovo1xu3poTeEtfapPlyfUJSVe+yxMnWCr76eLMizNMB
 J/Rg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=zi2f0mEfeTshxpFhqTOwWHvx3Bq7GLRDnAfDtleubxQ=;
 b=GkSZ5YOzikEM08EmgHlkexy6yiSTGgFD5zJoT0IxHR+rsmJlIvao2x9yMkF/+P/din
 WucPjkrJ8GNdTIGwj8ogTszOS23eMQ7ESG/QnbmcqB5yofBwwekJm1jeDikZALzLsBpp
 wAKiKsuE5Xs8KRQv9uR9/zbO1CDx2sfwYUYJYMTwYYdpgkHbjfriR/4SbElZWJCDImU+
 4bip5zNoKb3v1keX+drXWJ7jQNzYkMhMpIKbovrQx+5lJjCbBNxxTnWCX+4gfuX3AvaW
 EZEJJoId9TPEgphsLBXmEalLtufq1G8qiWy9sTWODOLZQ5hBiVnjQqcQqf3itOOz6rO4
 VcvQ==
X-Gm-Message-State: AOAM531hPpGMZdZQYeF7MlktZdkhbfhzhG6Qg7tRQkAjjmVC2pf9kWMk
 agjbnY4G42/16+tk2KG31MEFGIGc
X-Google-Smtp-Source: ABdhPJw2nI9PQ8v8emk6K2w4t2btY75W+8xfT+VGOTKSnOtHEHDYRCnBVMnGZ90NkIr4uVCGbGHXOQ==
X-Received: by 2002:a1c:1f41:: with SMTP id f62mr117930wmf.84.1590615136961;
 Wed, 27 May 2020 14:32:16 -0700 (PDT)
Received: from [192.168.0.3] ([66.205.73.129])
 by smtp.googlemail.com with ESMTPSA id u130sm4177082wmg.32.2020.05.27.14.32.15
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 27 May 2020 14:32:16 -0700 (PDT)
Subject: Re: bug#41441: 26.3; mhtml misbehaving font-lock extend region can
 cause Emacs to hang
To: Tom Tromey <tom@HIDDEN>, Anders Lindgren <andlind@HIDDEN>
References: <CABr8ebZWHZAFDyVfnHw6DSAQ9h3QSBaJZAW8AgknMwHPY-T-KQ@HIDDEN>
 <87pnasro4o.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <bea6c029-52b9-e718-0aaf-a610105f1a33@HIDDEN>
Date: Thu, 28 May 2020 00:32:15 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <87pnasro4o.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 41441
Cc: 41441 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 25.05.2020 19:11, Tom Tromey wrote:
> Looking at mhtml--submode-fontify-region, though, I wonder if maybe
> region extension isn't needed at all, since that function seems to
> handle sub-mode region boundaries.  So I guess that is one
> experiment that could be done.

That makes sense to me, and mirrors what mmm-mode currently does.

What if we just remove mhtml--extend-font-lock-region? Can anyone 
describe a scenario that would become broken?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#41441; Package emacs. Full text available.

Message received at 41441 <at> debbugs.gnu.org:


Received: (at 41441) by debbugs.gnu.org; 27 May 2020 20:41:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed May 27 16:41:30 2020
Received: from localhost ([127.0.0.1]:50076 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1je2rT-0002bu-Fp
	for submit <at> debbugs.gnu.org; Wed, 27 May 2020 16:41:30 -0400
Received: from mail-lf1-f53.google.com ([209.85.167.53]:46239)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <andlind@HIDDEN>) id 1je2rQ-0002bf-Ix
 for 41441 <at> debbugs.gnu.org; Wed, 27 May 2020 16:41:13 -0400
Received: by mail-lf1-f53.google.com with SMTP id r125so15236507lff.13
 for <41441 <at> debbugs.gnu.org>; Wed, 27 May 2020 13:41:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=cDLEkBnCjFd0nrPHCHuaj+D1yPY3ZVH6zc08RhfR2Mc=;
 b=p8pdBM9k4K5wmQKfM4oGDluoItniiXHkBlTgzwzLR4zRyJiFRvjEp2JhAGzPdwQ/h3
 NuLFhwUvP77ETf/FRcmzaCAPlGd6Q2nQZe4gpDw/Z20h4ROYLEDXn6+4uTCeQ6zf+cxt
 8ZtD6nLuvp8XOay9C5AmvbE5VtMWO3YcapvK/trkKvRNnwXGKrVRNh5O9wVCpsWDs42R
 bGYw1QCaWbccKw97oLOOzSKZVTeUFZCkj68SvnRwaRPzbp3jAylm6pIebZWnxPwHcEEd
 7PlbdyUGdzWe9mj6tLUy66sB49lqNORL1WO0X/mCUjyfvmOsDLwrtLFpFFW3r69MtJz/
 /XUw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=cDLEkBnCjFd0nrPHCHuaj+D1yPY3ZVH6zc08RhfR2Mc=;
 b=Pls84k3ATj6luuTam0rHgzrz9BA/s9o1MlmCS81vStV3vWVt1UTQOLucv/CJJiBIc/
 aQFRO+yea6LW8JNd26hnw2GTjWnsmmMAvMLD+FnubzS+SQDVZPP81rPJNK3E/EY5p5Dg
 stXFLmx/Pg7E+BvWJIAEvs3pU3PBCzr9LL/yAt8Cj+dzMHPQVdukoKNnw/iMa3ullQ7a
 XH81RBQZvXto5HLY6vKaKt7BqMJ8Odh+7cvTyDsKEfAzFlgg8IiPicstqg4p1lUqE3ZI
 JAfwd0MALmrd9wPLTdBUc1ZcFXlE9YgowLj5np1i9wW54uD/WJ75rGFVAAUW/yNl+Iab
 1tKA==
X-Gm-Message-State: AOAM533SZWazaqsNMwV521pvfiWdw0unGiBgJ5GlnfUg8nxZ3knmdBF8
 4BShyfL3UZxfvy5JsJe8fZxbpakBlaTS7t1UJnQO3sXO
X-Google-Smtp-Source: ABdhPJw+9s5LUdZeT5f0S4Gmlmz01lfef8EoIGUeIT8UfdRxiSiUocV4EHkPJeUfzt5uN6IMHYvWyI+vDNbEf01kEuo=
X-Received: by 2002:ac2:550a:: with SMTP id j10mr3879362lfk.46.1590612066354; 
 Wed, 27 May 2020 13:41:06 -0700 (PDT)
MIME-Version: 1.0
References: <CABr8ebZWHZAFDyVfnHw6DSAQ9h3QSBaJZAW8AgknMwHPY-T-KQ@HIDDEN>
 <87pnasro4o.fsf@HIDDEN>
In-Reply-To: <87pnasro4o.fsf@HIDDEN>
From: Anders Lindgren <andlind@HIDDEN>
Date: Wed, 27 May 2020 22:40:55 +0200
Message-ID: <CABr8ebaJxWtX16TL3-JUz6HqYftgima4O4UNXjaiTWDvE+H40w@HIDDEN>
Subject: Re: bug#41441: 26.3; mhtml misbehaving font-lock extend region can
 cause Emacs to hang
To: Tom Tromey <tom@HIDDEN>
Content-Type: multipart/alternative; boundary="00000000000030c90d05a6a73bd5"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 41441
Cc: 41441 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--00000000000030c90d05a6a73bd5
Content-Type: text/plain; charset="UTF-8"

Hi!

To me it's obviously a bug. First, the name of the function contains
"extend", not "change". Secondly, the loop in
font-lock-default-fontify-region is written so that it loops until all
functions in font-lock-extend-region-functions are satisfied (which is also
documented). To me, when code is written this way it's clear that monotonic
growth of the region is assumed (even though that isn't explicitly stated
in the documentation).

Anyway, I took a look at the mhtml code today. This is from
mhtml--extend-font-lock-region:

      (goto-char font-lock-beg)
      (unless (eobp)
        (forward-char))
      (setq font-lock-beg (previous-single-property-change
                           (point) 'mhtml-submode nil
                           (line-beginning-position)))

Without having a deep knowledge of this, I don't think this do the correct
thing when font-lock-beg is at the end of a line (as it is when the line is
empty). The problem is that the code move forward one character (the
newline) and then search backward with line-beginning-position (i.e. the
beginning of the line following the original font-lock-beg) as limit,
effectively shrinking the region.


On Mon, May 25, 2020 at 6:11 PM Tom Tromey <tom@HIDDEN> wrote:

> Anders> * Fix the problem in `mhtml--extend-font-lock-region`.
>
> It's not entirely clear to me that (1) this is a bug, or (2) that it can
> be changed.
>
> My recollection is that mhtml mode has to shrink the region in some
> cases, because we don't want font-locking to extend beyond the end of a
> sub-mode.
>
> For example consider things like
>
> <script>some js here;</script><p>more html here</p>
>
> Here, we want to font-lock the body of the script using one set of
> rules, and the rest with another set.
>
> Looking at mhtml--submode-fontify-region, though, I wonder if maybe
> region extension isn't needed at all, since that function seems to
> handle sub-mode region boundaries.  So I guess that is one
> experiment that could be done.
>
> Anders> One minor mode that, when enabled, would cause Emacs to hang
> Anders> with the above buffer is
> Anders> https://github.com/Lindydancer/char-font-lock (this package
> Anders> highlights incorrect whitespace).
>
> Maybe this mode could be changed instead.


Unfortunately, with the current font-lock interface, it's not. (Well, at
least I haven't figured out a way to do it, and I've been writing Emacs
packages for 25 years.)

The problem is that when the "expand" function is called, the functions has
no way of knowing whether it's the first time it has been called, or if it
has been called repeatedly. Besides, what should it do if there is another
expand function that has adjusted the region in the opposite order? Who has
the right of way?

Anyway, it's not just a problem for this mode, but for all font-lock
packages that expand the region.

    -- Anders


>
> Tom
>

--00000000000030c90d05a6a73bd5
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi!</div><div><br></div><div>To me it&#39;s obviously=
 a bug. First, the name of the function contains &quot;extend&quot;, not &q=
uot;change&quot;. Secondly, the loop in font-lock-default-fontify-region is=
 written so that it loops until all functions in font-lock-extend-region-fu=
nctions are satisfied (which is also documented). To me, when code is writt=
en this=C2=A0way it&#39;s clear that monotonic growth of the region is assu=
med (even though that isn&#39;t explicitly stated in the documentation).</d=
iv><div><br></div><div>Anyway, I took a look at the mhtml code today. This =
is from mhtml--extend-font-lock-region:</div><div><br></div><div><pre>     =
 (goto-char font-lock-beg)
      (<span style=3D"color:rgb(205,0,205)">unless</span> (eobp)
        (forward-char))
      (<span style=3D"color:rgb(205,0,205)">setq</span> font-lock-beg (prev=
ious-single-property-change
                           (point) &#39;<span style=3D"color:rgb(127,127,12=
7)">mhtml-submode</span> nil
                           (line-beginning-position)))
</pre></div><div>Without having a deep knowledge of this, I don&#39;t think=
 this do the correct thing when font-lock-beg is at the end of a line (as i=
t is when the line is empty). The problem is that the code move forward one=
 character (the newline) and then search backward with line-beginning-posit=
ion (i.e. the beginning of the line following the original font-lock-beg) a=
s limit, effectively shrinking the region.</div><div><br></div><div><br></d=
iv><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Mon,=
 May 25, 2020 at 6:11 PM Tom Tromey &lt;<a href=3D"mailto:tom@HIDDEN" t=
arget=3D"_blank">tom@HIDDEN</a>&gt; wrote:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex">Anders&gt; * Fix the problem in `mhtml--ex=
tend-font-lock-region`.<br>
<br>
It&#39;s not entirely clear to me that (1) this is a bug, or (2) that it ca=
n<br>
be changed.<br>
<br>
My recollection is that mhtml mode has to shrink the region in some<br>
cases, because we don&#39;t want font-locking to extend beyond the end of a=
<br>
sub-mode.<br>
<br>
For example consider things like<br>
<br>
&lt;script&gt;some js here;&lt;/script&gt;&lt;p&gt;more html here&lt;/p&gt;=
<br>
<br>
Here, we want to font-lock the body of the script using one set of<br>
rules, and the rest with another set.<br>
<br>
Looking at mhtml--submode-fontify-region, though, I wonder if maybe<br>
region extension isn&#39;t needed at all, since that function seems to<br>
handle sub-mode region boundaries.=C2=A0 So I guess that is one<br>
experiment that could be done.<br>
<br>
Anders&gt; One minor mode that, when enabled, would cause Emacs to hang<br>
Anders&gt; with the above buffer is<br>
Anders&gt; <a href=3D"https://github.com/Lindydancer/char-font-lock" rel=3D=
"noreferrer" target=3D"_blank">https://github.com/Lindydancer/char-font-loc=
k</a> (this package<br>
Anders&gt; highlights incorrect whitespace).<br>
<br>
Maybe this mode could be changed instead.</blockquote><div><br></div><div>U=
nfortunately, with the current font-lock interface, it&#39;s not. (Well, at=
 least I haven&#39;t figured out a way to do it, and I&#39;ve been writing =
Emacs packages for 25 years.)</div><div><br></div><div>The problem is that =
when the &quot;expand&quot; function is called, the=C2=A0functions has no w=
ay of knowing whether it&#39;s the first time it has been called, or if it =
has been called repeatedly. Besides, what should it do if there is another =
expand function that has adjusted the region in the opposite order? Who has=
 the right of way?</div><div><br></div><div>Anyway, it&#39;s not just a pro=
blem for this mode, but for all font-lock packages that expand=C2=A0the reg=
ion.</div><div><br></div><div>=C2=A0 =C2=A0 -- Anders</div><div>=C2=A0</div=
><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border=
-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Tom<br>
</blockquote></div></div>

--00000000000030c90d05a6a73bd5--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#41441; Package emacs. Full text available.

Message received at 41441 <at> debbugs.gnu.org:


Received: (at 41441) by debbugs.gnu.org; 25 May 2020 16:11:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 25 12:11:09 2020
Received: from localhost ([127.0.0.1]:42276 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jdFgy-0008St-QS
	for submit <at> debbugs.gnu.org; Mon, 25 May 2020 12:11:09 -0400
Received: from gateway36.websitewelcome.com ([192.185.197.22]:18935)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tom@HIDDEN>) id 1jdFgv-0008SJ-UB
 for 41441 <at> debbugs.gnu.org; Mon, 25 May 2020 12:11:07 -0400
Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4])
 by gateway36.websitewelcome.com (Postfix) with ESMTP id 542E840CC6A21
 for <41441 <at> debbugs.gnu.org>; Mon, 25 May 2020 10:30:52 -0500 (CDT)
Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP
 id dFgujJQfsEfyqdFguj04ev; Mon, 25 May 2020 11:11:05 -0500
X-Authority-Reason: nr=8
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; 
 s=default;
 h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=51qtUDT76OtztpEhC/eBKwe6PLJTDSV1qVpiyXq5gu8=; b=PBzABMPFWVlSq8Zbk/BxiGwfWC
 3KatFgruYVt6mL+YMhX6bmUWLm0FLWWw5TIeGx5mnPqKOLAWxqrQ73Xon6YacPd0AAGIF413jzhgi
 F7ER7CcZVHgarxEKqA3OwcI37;
Received: from 174-16-104-48.hlrn.qwest.net ([174.16.104.48]:36022 helo=bapiya)
 by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 (Exim 4.92) (envelope-from <tom@HIDDEN>)
 id 1jdFgu-003vWS-H2; Mon, 25 May 2020 10:11:04 -0600
From: Tom Tromey <tom@HIDDEN>
To: Anders Lindgren <andlind@HIDDEN>
Subject: Re: bug#41441: 26.3; mhtml misbehaving font-lock extend region can
 cause Emacs to hang
References: <CABr8ebZWHZAFDyVfnHw6DSAQ9h3QSBaJZAW8AgknMwHPY-T-KQ@HIDDEN>
X-Attribution: Tom
Date: Mon, 25 May 2020 10:11:03 -0600
In-Reply-To: <CABr8ebZWHZAFDyVfnHw6DSAQ9h3QSBaJZAW8AgknMwHPY-T-KQ@HIDDEN>
 (Anders Lindgren's message of "Thu, 21 May 2020 22:14:00 +0200")
Message-ID: <87pnasro4o.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - box5379.bluehost.com
X-AntiAbuse: Original Domain - debbugs.gnu.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - tromey.com
X-BWhitelist: no
X-Source-IP: 174.16.104.48
X-Source-L: No
X-Exim-ID: 1jdFgu-003vWS-H2
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Source-Sender: 174-16-104-48.hlrn.qwest.net (bapiya) [174.16.104.48]:36022
X-Source-Auth: tom+tromey.com
X-Email-Count: 2
X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20=
X-Local-Domain: yes
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 41441
Cc: 41441 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)

Anders> * Fix the problem in `mhtml--extend-font-lock-region`.

It's not entirely clear to me that (1) this is a bug, or (2) that it can
be changed.

My recollection is that mhtml mode has to shrink the region in some
cases, because we don't want font-locking to extend beyond the end of a
sub-mode.
           
For example consider things like

<script>some js here;</script><p>more html here</p>

Here, we want to font-lock the body of the script using one set of
rules, and the rest with another set.

Looking at mhtml--submode-fontify-region, though, I wonder if maybe
region extension isn't needed at all, since that function seems to
handle sub-mode region boundaries.  So I guess that is one
experiment that could be done.

Anders> One minor mode that, when enabled, would cause Emacs to hang
Anders> with the above buffer is
Anders> https://github.com/Lindydancer/char-font-lock (this package
Anders> highlights incorrect whitespace).

Maybe this mode could be changed instead.

Tom




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#41441; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 21 May 2020 20:14:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 21 16:14:20 2020
Received: from localhost ([127.0.0.1]:57361 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jbra7-0005z2-NG
	for submit <at> debbugs.gnu.org; Thu, 21 May 2020 16:14:20 -0400
Received: from lists.gnu.org ([209.51.188.17]:56614)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <andlind@HIDDEN>) id 1jbra4-0005yu-Rr
 for submit <at> debbugs.gnu.org; Thu, 21 May 2020 16:14:18 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:44100)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <andlind@HIDDEN>) id 1jbra4-0003rX-M0
 for bug-gnu-emacs@HIDDEN; Thu, 21 May 2020 16:14:16 -0400
Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]:45575)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <andlind@HIDDEN>) id 1jbra2-0002ud-RL
 for bug-gnu-emacs@HIDDEN; Thu, 21 May 2020 16:14:16 -0400
Received: by mail-lj1-x229.google.com with SMTP id z18so9841342lji.12
 for <bug-gnu-emacs@HIDDEN>; Thu, 21 May 2020 13:14:14 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=ZeCKvJ7Z7FzIAUC8izFb3B6hyYlDsq/xxTDL2A+YRwk=;
 b=OQ/LZ0T20JuOIsoZaSLlfsmzalSy6TN/I+djG1kTnveklE0gtdb0372mqGq8cqJ02r
 GGA/9FggzgltBi1NElWK4jluIS1/v+mgy3RYaam0g8AYhU1B8xsmFXb7xY428xZ2jOTE
 si1Ym4JFsh+gOGGNmK7Js0dqJe6wrkaoOdoG+363ra3Uqs3RPI+H2gZ4LmkvA9V9m6Qf
 Afpx76hQGWPB3emOWQ4CUmKx7OPp82MO7vT7mppEbH8zYQcj3OxqlUZ/jVslwSOkbSQr
 KmmPy3FktcEn3lxxnuta/o/Nfa04hvlDgfjMl+AwI0pPOM0aLVxb0KyQrZYT7b6++NQU
 xZgQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=ZeCKvJ7Z7FzIAUC8izFb3B6hyYlDsq/xxTDL2A+YRwk=;
 b=BRSOkvjvm1bZyI0Y4yyvOZbg2Yh2X9uLsrB0fNgRCrZdojo2zV0kVTjEzOzlQLF8Z9
 03/ua+amKdDoGbzXzEed2ar83jynX5NbI1y0yZoBuTjtWV3cYDY4m1A2UTQDaSrMAznl
 MXVTBUEWtKjBtx7KFxJ47aUhY86IScTD/h+MJNVDsbxK97t3w/bK4LpLPOzRfTAaBF57
 D6JTE+Np7OqdTqv18eNKlFjsqskcXMZuiurYbvzVLS2jWAUrO01ymmn6qE0pWhySrU92
 /yRaZZNCzFY4/Q3dUpf7kqb8YYSWQEl67u7qcLZ+H8Ow59q8c4oHxcQxo2I8cRiSnyfB
 j1Nw==
X-Gm-Message-State: AOAM530n2JepWuKlip9fpigWoqHCtNztk4uxFGZKF65DdQjnAPUo/68A
 AlwOSpK8uuv50LEc/yYFCssnk70VP9GfzBX/3UxvLdFo/uQ=
X-Google-Smtp-Source: ABdhPJyzFXCrd68/gW6Pn84K8/hRWjCLYbEWWYxnxiXxCAomz4VzgZh4sykbYd0fTpelQKu0fw5ohSYSamcHQwmvHHk=
X-Received: by 2002:a05:651c:209:: with SMTP id
 y9mr4039034ljn.408.1590092051861; 
 Thu, 21 May 2020 13:14:11 -0700 (PDT)
MIME-Version: 1.0
From: Anders Lindgren <andlind@HIDDEN>
Date: Thu, 21 May 2020 22:14:00 +0200
Message-ID: <CABr8ebZWHZAFDyVfnHw6DSAQ9h3QSBaJZAW8AgknMwHPY-T-KQ@HIDDEN>
Subject: 26.3;
 mhtml misbehaving font-lock extend region can cause Emacs to hang
To: bug-gnu-emacs@HIDDEN
Content-Type: multipart/alternative; boundary="000000000000e9534b05a62e2732"
Received-SPF: pass client-ip=2a00:1450:4864:20::229;
 envelope-from=andlind@HIDDEN; helo=mail-lj1-x229.google.com
X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache.
 That's all we know.
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001,
 URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN
X-Spam_action: no action
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--000000000000e9534b05a62e2732
Content-Type: text/plain; charset="UTF-8"

Hi!

The font-lock system provides a system for major and minor modes to extend
the region that is being highlighted.

In Mhtml mode, the function `mhtml--extend-font-lock-region` sometimes
reduce the size of the region. If this is combined with, say, a minor mode
that extends the region then Emacs could hang.

Steps to repeat:

Create a file, test.html, with the following content:

---------
alpha

beta
---------

Evaluate:

(let ((font-lock-beg 7)
      (font-lock-end 13))
  (mhtml--extend-font-lock-region)
  (cons font-lock-beg font-lock-end))

The 7 and 13 corresponds to a region that includes the last two lines. The
expression returns (8 . 13) representing a region that only include the
last line. If this is combined with another function that extends the
region to include line 2, Emacs hangs.

I suggest that:

* Modify the documentation of the variable
`font-lock-extend-region-functions` so that it's clear that the region
should not shrink.

* Add a check in the function `font-lock-default-fontify-region` to prevent
the region from shrinking even if a function tries to do so. (By ensuring
that the region only extends and never shrinks, the function will always
terminate.)

* Fix the problem in `mhtml--extend-font-lock-region`.

One minor mode that, when enabled, would cause Emacs to hang with the above
buffer is https://github.com/Lindydancer/char-font-lock (this package
highlights incorrect whitespace).

    -- Anders Lindgren




1) The function `mhtml--extend-font-lock-region should be modified so that
it never shrinks the region.


In GNU Emacs 26.3 (build 1, x86_64-apple-darwin14.5.0, NS appkit-1348.17
Version 10.10.5 (Build 14F2511))
 of 2019-09-02 built on builder10-10.porkrind.org
Windowing system distributor 'Apple', version 10.3.1348
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
(New file)
funcall-interactively: End of buffer
Saving file /Users/anders/emacs/src/foreach/foo.html...
Wrote /Users/anders/emacs/src/foreach/foo.html
Char: C-j (10, #o12, #xa) point=7 of 12 (50%) column=0
Quit
Entering debugger...
Back to top level
(8 . 13) [2 times]
Configured using:
 'configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp' --with-modules'

Configured features:
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS

Important settings:
  value of $LC_CTYPE: UTF-8
  value of $LANG: en_SE.UTF-8
  locale-coding-system: utf-8-unix

Major mode: HTML+

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils cl-print debug help-fns
radix-tree help-mode vc-dispatcher vc-svn mhtml-mode css-mode smie color
js advice json map imenu thingatpt cc-mode cc-fonts easymenu cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs sgml-mode
seq byte-opt gv bytecomp byte-compile cconv dom cl-loaddefs cl-lib
elec-pair time-date tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads kqueue cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 244001 21210)
 (symbols 48 23926 1)
 (miscs 40 81 268)
 (strings 32 43844 1478)
 (string-bytes 1 1234265)
 (vectors 16 39716)
 (vector-slots 8 775521 10394)
 (floats 8 209 245)
 (intervals 56 230 0)
 (buffers 992 14))

--000000000000e9534b05a62e2732
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi!<div><br></div><div>The font-lock system provides a sys=
tem for major and minor modes to extend the region that is being highlighte=
d.</div><div><br></div><div>In Mhtml mode, the function `mhtml--extend-font=
-lock-region` sometimes reduce the size of the region. If this is combined =
with, say, a minor mode that extends the region then Emacs could hang.</div=
><div><br></div><div>Steps to repeat:</div><div><br></div><div>Create a fil=
e, test.html, with the following content:</div><div><br></div><div>--------=
-</div><div>alpha</div><div><br></div><div>beta<br>---------</div><div><br>=
</div><div>Evaluate:</div><div><br></div><div>(let ((font-lock-beg 7)<br>=
=C2=A0 =C2=A0 =C2=A0 (font-lock-end 13))<br>=C2=A0 (mhtml--extend-font-lock=
-region)<br>=C2=A0 (cons font-lock-beg font-lock-end))<br><br>The 7 and 13 =
corresponds to a region that includes the last two lines. The expression re=
turns (8 . 13) representing a region that only include the last line. If th=
is is combined with another function that extends the region to include lin=
e 2, Emacs hangs.</div><div><br></div><div>I suggest that:</div><div><br></=
div><div>* Modify the documentation of the variable `font-lock-extend-regio=
n-functions` so that it&#39;s clear that the region should not shrink.</div=
><div><br></div><div>* Add a check in the function `font-lock-default-fonti=
fy-region` to prevent the region from shrinking even if a function tries to=
 do so. (By ensuring that the region only extends and never shrinks, the fu=
nction will always terminate.)</div><div><br></div><div>* Fix the problem i=
n `mhtml--extend-font-lock-region`.</div><div><br></div><div>One minor mode=
 that, when enabled, would cause Emacs to hang with the above buffer is <a =
href=3D"https://github.com/Lindydancer/char-font-lock">https://github.com/L=
indydancer/char-font-lock</a> (this package highlights incorrect whitespace=
).</div><div><br></div><div>=C2=A0 =C2=A0 -- Anders Lindgren</div><div><br>=
</div><div><br></div><div><br></div><div><br></div><div>1) The function `mh=
tml--extend-font-lock-region should be modified so that it never shrinks th=
e region.</div><div><br></div><div>=C2=A0<br>In GNU Emacs 26.3 (build 1, x8=
6_64-apple-darwin14.5.0, NS appkit-1348.17 Version 10.10.5 (Build 14F2511))=
<br>=C2=A0of 2019-09-02 built on <a href=3D"http://builder10-10.porkrind.or=
g">builder10-10.porkrind.org</a><br>Windowing system distributor &#39;Apple=
&#39;, version 10.3.1348<br>Recent messages:<br>For information about GNU E=
macs and the GNU system, type C-h C-a.<br>(New file)<br>funcall-interactive=
ly: End of buffer<br>Saving file /Users/anders/emacs/src/foreach/foo.html..=
.<br>Wrote /Users/anders/emacs/src/foreach/foo.html<br>Char: C-j (10, #o12,=
 #xa) point=3D7 of 12 (50%) column=3D0<br>Quit<br>Entering debugger...<br>B=
ack to top level<br>(8 . 13) [2 times]<br>Configured using:<br>=C2=A0&#39;c=
onfigure --with-ns &#39;--enable-locallisppath=3D/Library/Application<br>=
=C2=A0Support/Emacs/${version}/site-lisp:/Library/Application<br>=C2=A0Supp=
ort/Emacs/site-lisp&#39; --with-modules&#39;<br><br>Configured features:<br=
>NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS<br><=
br>Important settings:<br>=C2=A0 value of $LC_CTYPE: UTF-8<br>=C2=A0 value =
of $LANG: en_SE.UTF-8<br>=C2=A0 locale-coding-system: utf-8-unix<br><br>Maj=
or mode: HTML+<br><br>Minor modes in effect:<br>=C2=A0 tooltip-mode: t<br>=
=C2=A0 global-eldoc-mode: t<br>=C2=A0 electric-indent-mode: t<br>=C2=A0 mou=
se-wheel-mode: t<br>=C2=A0 tool-bar-mode: t<br>=C2=A0 menu-bar-mode: t<br>=
=C2=A0 file-name-shadow-mode: t<br>=C2=A0 global-font-lock-mode: t<br>=C2=
=A0 font-lock-mode: t<br>=C2=A0 blink-cursor-mode: t<br>=C2=A0 auto-composi=
tion-mode: t<br>=C2=A0 auto-encryption-mode: t<br>=C2=A0 auto-compression-m=
ode: t<br>=C2=A0 line-number-mode: t<br>=C2=A0 transient-mark-mode: t<br><b=
r>Load-path shadows:<br>None found.<br><br>Features:<br>(shadow sort mail-e=
xtr emacsbug message rmc puny dired dired-loaddefs<br>format-spec rfc822 mm=
l mml-sec password-cache epa derived epg epg-config<br>gnus-util rmail rmai=
l-loaddefs mm-decode mm-bodies mm-encode mail-parse<br>rfc2231 mailabbrev g=
mm-utils mailheader sendmail rfc2047 rfc2045<br>ietf-drums mm-util mail-prs=
vr mail-utils cl-print debug help-fns<br>radix-tree help-mode vc-dispatcher=
 vc-svn mhtml-mode css-mode smie color<br>js advice json map imenu thingatp=
t cc-mode cc-fonts easymenu cc-guess<br>cc-menus cc-cmds cc-styles cc-align=
 cc-engine cc-vars cc-defs sgml-mode<br>seq byte-opt gv bytecomp byte-compi=
le cconv dom cl-loaddefs cl-lib<br>elec-pair time-date tooltip eldoc electr=
ic uniquify ediff-hook vc-hooks<br>lisp-float-type mwheel term/ns-win ns-wi=
n ucs-normalize mule-util<br>term/common-win tool-bar dnd fontset image reg=
exp-opt fringe<br>tabulated-list replace newcomment text-mode elisp-mode li=
sp-mode<br>prog-mode register page menu-bar rfn-eshadow isearch timer selec=
t<br>scroll-bar mouse jit-lock font-lock syntax facemenu font-core<br>term/=
tty-colors frame cl-generic cham georgian utf-8-lang misc-lang<br>vietnames=
e tibetan thai tai-viet lao korean japanese eucjp-ms cp51932<br>hebrew gree=
k romanian slovak czech european ethiopic indian cyrillic<br>chinese compos=
ite charscript charprop case-table epa-hook jka-cmpr-hook<br>help simple ab=
brev obarray minibuffer cl-preloaded nadvice loaddefs<br>button faces cus-f=
ace macroexp files text-properties overlay sha1 md5<br>base64 format env co=
de-pages mule custom widget hashtable-print-readable<br>backquote threads k=
queue cocoa ns multi-tty make-network-process emacs)<br><br>Memory informat=
ion:<br>((conses 16 244001 21210)<br>=C2=A0(symbols 48 23926 1)<br>=C2=A0(m=
iscs 40 81 268)<br>=C2=A0(strings 32 43844 1478)<br>=C2=A0(string-bytes 1 1=
234265)<br>=C2=A0(vectors 16 39716)<br>=C2=A0(vector-slots 8 775521 10394)<=
br>=C2=A0(floats 8 209 245)<br>=C2=A0(intervals 56 230 0)<br>=C2=A0(buffers=
 992 14))<br></div></div>

--000000000000e9534b05a62e2732--




Acknowledgement sent to Anders Lindgren <andlind@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#41441; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 27 May 2020 21:45:02 UTC

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