From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#10664: 24.0.93; JIT font-lock infloops in a C file Date: Fri, 10 Feb 2012 11:28:57 +0000 Message-ID: <20120210112857.GA4340@acm.acm> References: <83wr89qcay.fsf@gnu.org> <83bopdcfe5.fsf@gnu.org> <20120206110957.GA2731@acm.acm> <83wr7zc2r2.fsf@gnu.org> <20120207192032.GA17530@acm.acm> <83y5se9x9a.fsf@gnu.org> <20120207213401.GB17530@acm.acm> <20120208114749.GA3523@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1328873413 14852 80.91.229.3 (10 Feb 2012 11:30:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Feb 2012 11:30:13 +0000 (UTC) Cc: 10664@debbugs.gnu.org To: Eli Zaretskii , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Feb 10 12:30:10 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rvog2-00051r-VX for geb-bug-gnu-emacs@m.gmane.org; Fri, 10 Feb 2012 12:30:07 +0100 Original-Received: from localhost ([::1]:39585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvog2-0006hG-7f for geb-bug-gnu-emacs@m.gmane.org; Fri, 10 Feb 2012 06:30:06 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:35053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvofv-0006du-Ba for bug-gnu-emacs@gnu.org; Fri, 10 Feb 2012 06:30:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rvofr-00062T-02 for bug-gnu-emacs@gnu.org; Fri, 10 Feb 2012 06:29:59 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59297) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvofl-00061i-R7; Fri, 10 Feb 2012 06:29:49 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Rvogv-0006hF-VG; Fri, 10 Feb 2012 06:31:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Fri, 10 Feb 2012 11:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10664 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 10664-submit@debbugs.gnu.org id=B10664.132887343325703 (code B ref 10664); Fri, 10 Feb 2012 11:31:01 +0000 Original-Received: (at 10664) by debbugs.gnu.org; 10 Feb 2012 11:30:33 +0000 Original-Received: from localhost ([127.0.0.1]:34687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RvogT-0006gV-5C for submit@debbugs.gnu.org; Fri, 10 Feb 2012 06:30:33 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:23664 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RvogQ-0006gM-91 for 10664@debbugs.gnu.org; Fri, 10 Feb 2012 06:30:31 -0500 Original-Received: (qmail 98969 invoked by uid 3782); 10 Feb 2012 11:29:15 -0000 Original-Received: from acm.muc.de (pD9556CC4.dip.t-dialin.net [217.85.108.196]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 10 Feb 2012 12:29:12 +0100 Original-Received: (qmail 4468 invoked by uid 1000); 10 Feb 2012 11:28:57 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.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:56758 Archived-At: Hi, Eli and Stefan. On Wed, Feb 08, 2012 at 02:28:53PM -0500, Stefan Monnier wrote: > >> > For one particular fontification in socket.c, the "safe position" is 500 > >> > bytes back from the starting point, so jit-lock is pushed back these 500 > >> > bytes, fontifies the next 500 bytes (`jit-lock-chunk-size'), then has its > >> > new start position set back 500 bytes, rinse, spin, repeat. > >> Why is "jit-lock pushed back"? > > Build Emacs revision #106728. emacs -Q, then create the following C++ > > buffer: > > ######################################################################### > > 1 template > > 2 > > 3 > > 4 void myfunc(T* p) {} > > ######################################################################### > > This is fontified correctly. Type a space on L2. This is OK for half a > > second, then context fontification messes up L4. The correct > > fontification can only be restored by a change to L4. > That explains why *font-lock* needs to be applied to "L1-L4", but now > why *jit-lock* needs to be affected. I was mistaken in my original diagnosis. What is really happening is that CC Mode is trying to go out of nested parens/brackets to find the beginning of a declaration. c-beginning-of-decl-1 (which _never_ goes back outside of parens/brackets/braces) was given a limit (- (point) 500) which took it to just after a (. Then we went back out of the (. Then did c-beginning-of-decl-1 again, which moved _forward_ to the limit. Repeat, repeat, repeat ad infinitum. The following patch should fix this. Eli, would you please try it out and let me know if there are still problems with it. *** orig/cc-mode.el 2012-02-10 10:55:54.000000000 +0000 --- cc-mode.el 2012-02-10 11:27:56.000000000 +0000 *************** *** 1140,1146 **** (goto-char (c-point 'bol new-pos)) (when lit-limits ; Comment or string. (goto-char (car lit-limits))) ! (setq bod-lim (max (- (point) 500) (point-min))) (while ;; Go to a less nested declaration each time round this loop. --- 1140,1146 ---- (goto-char (c-point 'bol new-pos)) (when lit-limits ; Comment or string. (goto-char (car lit-limits))) ! (setq bod-lim (c-determine-limit 500)) (while ;; Go to a less nested declaration each time round this loop. *************** *** 1158,1168 **** ;; Try and go out a level to search again. (progn (c-backward-syntactic-ws bod-lim) ! (or (memq (char-before) '(?\( ?\[)) ! (and (eq (char-before) ?\<) ! (eq (c-get-char-property ! (1- (point)) 'syntax-table) ! c-<-as-paren-syntax)))) (not (bobp))) (backward-char)) new-pos)) ; back over (, [, <. --- 1158,1169 ---- ;; Try and go out a level to search again. (progn (c-backward-syntactic-ws bod-lim) ! (and (> (point) bod-lim) ! (or (memq (char-before) '(?\( ?\[)) ! (and (eq (char-before) ?\<) ! (eq (c-get-char-property ! (1- (point)) 'syntax-table) ! c-<-as-paren-syntax))))) (not (bobp))) (backward-char)) new-pos)) ; back over (, [, <. > Stefan -- Alan Mackenzie (Nuremberg, Germany).