From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: brubar.cs@gmail.com Newsgroups: gmane.emacs.bugs Subject: bug#21615: 24.5; font-lock-extend-region-wholelines' infinite loop Date: Sun, 04 Oct 2015 19:34:07 +0200 Message-ID: <87a8ryczcg.fsf@tosh-laptop.i-did-not-set--mail-host-address--so-tickle-me> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1443979106 31065 80.91.229.3 (4 Oct 2015 17:18:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 4 Oct 2015 17:18:26 +0000 (UTC) To: 21615@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 04 19:18:15 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZimvN-0006ep-Pk for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Oct 2015 19:18:14 +0200 Original-Received: from localhost ([::1]:43153 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZimvN-0004jl-6q for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Oct 2015 13:18:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZimvG-0004fZ-8q for bug-gnu-emacs@gnu.org; Sun, 04 Oct 2015 13:18:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZimvD-0006MR-1r for bug-gnu-emacs@gnu.org; Sun, 04 Oct 2015 13:18:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37328) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZimvC-0006ML-V4 for bug-gnu-emacs@gnu.org; Sun, 04 Oct 2015 13:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZimvC-0001ly-Hw for bug-gnu-emacs@gnu.org; Sun, 04 Oct 2015 13:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: brubar.cs@gmail.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Oct 2015 17:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21615 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14439790666789 (code B ref -1); Sun, 04 Oct 2015 17:18:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Oct 2015 17:17:46 +0000 Original-Received: from localhost ([127.0.0.1]:54532 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zimuv-0001lQ-D7 for submit@debbugs.gnu.org; Sun, 04 Oct 2015 13:17:45 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51843) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zimut-0001lJ-UW for submit@debbugs.gnu.org; Sun, 04 Oct 2015 13:17:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zimus-0006Dn-N7 for submit@debbugs.gnu.org; Sun, 04 Oct 2015 13:17:43 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:44482) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zimus-0006Di-J1 for submit@debbugs.gnu.org; Sun, 04 Oct 2015 13:17:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zimur-00042L-3e for bug-gnu-emacs@gnu.org; Sun, 04 Oct 2015 13:17:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zimun-0006Co-T9 for bug-gnu-emacs@gnu.org; Sun, 04 Oct 2015 13:17:41 -0400 Original-Received: from smtp4-g21.free.fr ([2a01:e0c:1:1599::13]:26735) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zimun-0006Cc-Hb for bug-gnu-emacs@gnu.org; Sun, 04 Oct 2015 13:17:37 -0400 Original-Received: from tosh-laptop (unknown [78.240.71.23]) by smtp4-g21.free.fr (Postfix) with ESMTPS id 856394C80C9 for ; Sun, 4 Oct 2015 19:17:35 +0200 (CEST) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:107291 Archived-At: The function `font-lock-extend-region-wholelines' uses `bolp' to check if point is at the beginning of the line, and, if not, it calls `line-beginning-position' to move to the beginning of the line. Here is the code from `font-lock-extend-region-wholelines': ,---- | (goto-char font-lock-beg) | (unless (bolp) | (setq changed t font-lock-beg (line-beginning-position))) `---- But, `line-beginning-position' moves to the beginning of the line *OR* to the beginning of a *field*. Thus, if point is at the beginning of a field that is not at the beginning of a line, `changed' is set to t but the region is not changed. As `font-lock-extend-region-wholelines' is called again until it doesn't signal a change, we end up in an infinite loop. To reproduce, use the attached file and run it like that: ,---- | emacs -Q --file test-font-lock-infloop.el --eval '(progn (eval-buffer) (DO-NOT-EVAL-ME))' `---- Bruno. In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.9) of 2015-09-22 on tosh-laptop Windowing system distributor `The X.Org Foundation', version 11.0.11502000 Configured using: `configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --disable-dependency-tracking --disable-silent-rules --libdir=/usr/lib64 --program-suffix=-emacs-24 --infodir=/usr/share/info/emacs-24 --localstatedir=/var --enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp --with-gameuser=:gamestat --without-compress-install --with-file-notification=inotify --enable-acl --with-dbus --without-gnutls --without-gpm --without-hesiod --without-kerberos --without-kerberos5 --with-xml2 --without-selinux --without-wide-int --with-zlib --with-sound=alsa --with-x --without-ns --without-gconf --without-gsettings --without-toolkit-scroll-bars --without-gif --with-jpeg --with-png --with-rsvg --without-tiff --with-xpm --with-imagemagick --with-xft --without-libotf --without-m17n-flt --with-x-toolkit=gtk3 GENTOO_PACKAGE=app-editors/emacs-24.5 'CFLAGS=-O2 -pipe -march=native' CPPFLAGS= 'LDFLAGS=-Wl,-O1 -Wl,--as-needed'' Important settings: value of $LC_CTYPE: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-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 Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Quit current-kill: Kill ring is empty delete-backward-char: Text is read-only Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util help-fns mail-prsvr mail-utils time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer 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 make-network-process dbusbind inotify dynamic-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs) Memory information: ((conses 16 71404 9137) (symbols 48 17534 0) (miscs 40 37 138) (strings 32 9208 4463) (string-bytes 1 253754) (vectors 16 8909) (vector-slots 8 383166 18279) (floats 8 63 99) (intervals 56 222 10) (buffers 960 11) (heap 1024 24783 718)) ===File /home/bruno/WorkingDirectory/Community/Emacs/Gnu-Emacs/test-font-lock-infloop.el=== (defun DO-NOT-EVAL-ME () "FREEZE YOUR EMACS. DO NOT RUN IN YOUR MAIN EMACS. Run this file as follows: emacs -Q --file test-font-lock-infloop.el --eval '(progn (eval-buffer) (DO-NOT-EVAL-ME))' Then, type something between \"TYPE HERE==>>>\" and \"<<<==TYPE HERE\". Your Emacs should now hangs. GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.9) But should work with any Emacs." ;; Publish our own custom function to extend the region to fontify. ;; ;; The first function can say whatever it wants (changed=t or ;; nil), it's ignored. Thus, we need to push ;; `font-lock-extend-region-wholelines' into the second position ;; to show the bug. ;; (add-hook 'font-lock-extend-region-functions (lambda () :whatever)) ;; Put a 'field property between the two "TYPE HERE" below. ;; Typing there will make Emacs hangs ... well, if not before. ;; (let ((beg (re-search-forward "TYPE HERE==>>>")) (end (re-search-forward "<<<==TYPE HERE")) ) (add-text-properties beg end '(field :hang front-sticky t)) )) (DO-NOT-EVAL-ME) ;; TYPE HERE==>>> <<<==TYPE HERE ============================================================