From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Anders Lindgren Newsgroups: gmane.emacs.bugs Subject: bug#41441: 26.3; mhtml misbehaving font-lock extend region can cause Emacs to hang Date: Thu, 21 May 2020 22:14:00 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000e9534b05a62e2732" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="97932"; mail-complaints-to="usenet@ciao.gmane.io" To: 41441@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 21 22:15:21 2020 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 1jbrb4-000PHV-PQ for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 May 2020 22:15:18 +0200 Original-Received: from localhost ([::1]:57570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbrb3-0004Kn-BF for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 May 2020 16:15:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbrao-0004Ka-VQ for bug-gnu-emacs@gnu.org; Thu, 21 May 2020 16:15:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45815) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbrao-0003Kj-MF for bug-gnu-emacs@gnu.org; Thu, 21 May 2020 16:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jbrao-00060N-Hr for bug-gnu-emacs@gnu.org; Thu, 21 May 2020 16:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Anders Lindgren Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 May 2020 20:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41441 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.159009206023010 (code B ref -1); Thu, 21 May 2020 20:15:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 May 2020 20:14:20 +0000 Original-Received: from localhost ([127.0.0.1]:57361 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jbra7-0005z2-NG for submit@debbugs.gnu.org; Thu, 21 May 2020 16:14:20 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:56614) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jbra4-0005yu-Rr for submit@debbugs.gnu.org; Thu, 21 May 2020 16:14:18 -0400 Original-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 ) id 1jbra4-0003rX-M0 for bug-gnu-emacs@gnu.org; Thu, 21 May 2020 16:14:16 -0400 Original-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 ) id 1jbra2-0002ud-RL for bug-gnu-emacs@gnu.org; Thu, 21 May 2020 16:14:16 -0400 Original-Received: by mail-lj1-x229.google.com with SMTP id z18so9841342lji.12 for ; 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) Received-SPF: pass client-ip=2a00:1450:4864:20::229; envelope-from=andlind@gmail.com; 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-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:180717 Archived-At: --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
Hi!

The font-lock system provides a sys= tem for major and minor modes to extend the region that is being highlighte= d.

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 fil= e, test.html, with the following content:

--------= -
alpha

beta
---------

=
Evaluate:

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

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.

I suggest that:

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

* 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.)

* Fix the problem i= n `mhtml--extend-font-lock-region`.

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

=C2=A0 =C2=A0 -- Anders Lindgren

=



1) The function `mh= tml--extend-font-lock-region should be modified so that it never shrinks th= e region.

=C2=A0
In GNU Emacs 26.3 (build 1, x8= 6_64-apple-darwin14.5.0, NS appkit-1348.17 Version 10.10.5 (Build 14F2511))=
=C2=A0of 2019-09-02 built on builder10-10.porkrind.org
Windowing system distributor 'Apple= ', version 10.3.1348
Recent messages:
For information about GNU E= macs and the GNU system, type C-h C-a.
(New file)
funcall-interactive= ly: 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=3D7 of 12 (50%) column=3D0
Quit
Entering debugger...
B= ack to top level
(8 . 13) [2 times]
Configured using:
=C2=A0'c= onfigure --with-ns '--enable-locallisppath=3D/Library/Application
= =C2=A0Support/Emacs/${version}/site-lisp:/Library/Application
=C2=A0Supp= ort/Emacs/site-lisp' --with-modules'

Configured features:NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS
<= br>Important settings:
=C2=A0 value of $LC_CTYPE: UTF-8
=C2=A0 value = of $LANG: en_SE.UTF-8
=C2=A0 locale-coding-system: utf-8-unix

Maj= or mode: HTML+

Minor modes in effect:
=C2=A0 tooltip-mode: t
= =C2=A0 global-eldoc-mode: t
=C2=A0 electric-indent-mode: t
=C2=A0 mou= se-wheel-mode: t
=C2=A0 tool-bar-mode: t
=C2=A0 menu-bar-mode: t
= =C2=A0 file-name-shadow-mode: t
=C2=A0 global-font-lock-mode: t
=C2= =A0 font-lock-mode: t
=C2=A0 blink-cursor-mode: t
=C2=A0 auto-composi= tion-mode: t
=C2=A0 auto-encryption-mode: t
=C2=A0 auto-compression-m= ode: t
=C2=A0 line-number-mode: t
=C2=A0 transient-mark-mode: t
Load-path shadows:
None found.

Features:
(shadow sort mail-e= xtr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mm= l mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmai= l-loaddefs mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev g= mm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prs= vr 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 thingatp= t 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-compi= le cconv dom cl-loaddefs cl-lib
elec-pair time-date tooltip eldoc electr= ic uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/ns-win ns-wi= n ucs-normalize mule-util
term/common-win tool-bar dnd fontset image reg= exp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode li= sp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer selec= t
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/= tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnames= e tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew gree= k romanian slovak czech european ethiopic indian cyrillic
chinese compos= ite charscript charprop case-table epa-hook jka-cmpr-hook
help simple ab= brev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-f= ace macroexp files text-properties overlay sha1 md5
base64 format env co= de-pages mule custom widget hashtable-print-readable
backquote threads k= queue cocoa ns multi-tty make-network-process emacs)

Memory informat= ion:
((conses 16 244001 21210)
=C2=A0(symbols 48 23926 1)
=C2=A0(m= iscs 40 81 268)
=C2=A0(strings 32 43844 1478)
=C2=A0(string-bytes 1 1= 234265)
=C2=A0(vectors 16 39716)
=C2=A0(vector-slots 8 775521 10394)<= br>=C2=A0(floats 8 209 245)
=C2=A0(intervals 56 230 0)
=C2=A0(buffers= 992 14))
--000000000000e9534b05a62e2732--