From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#33784: Date: Thu, 20 Dec 2018 12:53:26 +0000 Message-ID: <20181220125326.GA4404__34300.4354429015$1545310813$gmane$org@ACM> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1545310813 7838 195.159.176.226 (20 Dec 2018 13:00:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 20 Dec 2018 13:00:13 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 33784-done@debbugs.gnu.org To: xh yang Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 20 14:00:08 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gZxvq-0001sO-Hm for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Dec 2018 14:00:06 +0100 Original-Received: from localhost ([::1]:37296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZxxx-0001gx-6M for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Dec 2018 08:02:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZxvo-0000Ti-EY for bug-gnu-emacs@gnu.org; Thu, 20 Dec 2018 08:00:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZxvm-0008HE-N0 for bug-gnu-emacs@gnu.org; Thu, 20 Dec 2018 08:00:04 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZxvm-0008H0-IL; Thu, 20 Dec 2018 08:00:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gZxvm-0000jj-Hb; Thu, 20 Dec 2018 08:00:02 -0500 Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Thu, 20 Dec 2018 13:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 33784 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Mail-Followup-To: 33784@debbugs.gnu.org, acm@muc.de, linux.xhyang@gmail.com Original-Received: via spool by 33784-done@debbugs.gnu.org id=D33784.15453107962782 (code D ref 33784); Thu, 20 Dec 2018 13:00:02 +0000 Original-Received: (at 33784-done) by debbugs.gnu.org; 20 Dec 2018 12:59:56 +0000 Original-Received: from localhost ([127.0.0.1]:55576 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gZxvg-0000io-I1 for submit@debbugs.gnu.org; Thu, 20 Dec 2018 07:59:56 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:20847 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1gZxve-0000ie-7W for 33784-done@debbugs.gnu.org; Thu, 20 Dec 2018 07:59:54 -0500 Original-Received: (qmail 74870 invoked by uid 3782); 20 Dec 2018 12:59:52 -0000 Original-Received: from acm.muc.de (p2E5D57C9.dip0.t-ipconnect.de [46.93.87.201]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 20 Dec 2018 13:59:52 +0100 Original-Received: (qmail 4425 invoked by uid 1000); 20 Dec 2018 12:53:26 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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" Xref: news.gmane.org gmane.emacs.bugs:153638 Archived-At: Hello, xh. On Thu, Dec 20, 2018 at 15:18:49 +0800, xh yang wrote: > I found if remove first '\n' from the *str,then run emacs will not hang.* > *May be it has nothing to do with font-lock, just str parsing ?* Sorry for all the distraction in the last couple of days. As you suggested in your opening post, the problem was a simple infinite loop involving c-backward-token-2. This was in CC Mode's font-locking code. I've committed a fix to the emacs-26 branch, and it should find its way to the master branch within a few days. I'm closing the bug. Here is the patch: # HG changeset patch # User Alan Mackenzie # Date 1545307557 0 # Thu Dec 20 12:05:57 2018 +0000 # Node ID 5319aa054ccb77924e19b836093c9e1b3ff91d4b # Parent a3f28b92890acc5289cde497ea1335f4b39239d7 Check result from c-backward-token-2 to avoid infinite loop This fixes bug #33784. * cc-fonts.el (c-get-fontification-context): While moving back over enclosing parentheses, check that c-backward-token-2 actually moves. diff -r a3f28b92890a -r 5319aa054ccb cc-fonts.el --- a/cc-fonts.el Thu Dec 20 12:04:53 2018 +0000 +++ b/cc-fonts.el Thu Dec 20 12:05:57 2018 +0000 @@ -1255,8 +1255,8 @@ (save-excursion (goto-char match-pos) (while - (progn (c-backward-token-2) - (eq (char-after) ?\())) + (and (zerop (c-backward-token-2)) + (eq (char-after) ?\())) (looking-at c-arithmetic-op-regexp))) (cons nil nil)) ;; In a C++ member initialization list. Thanks, once more, for the bug report. -- Alan Mackenzie (Nuremberg, Germany).