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#28850: 26.0.90; Error running timer 'jit-lock-stealth-fontify': (error "Invalid search bound (wrong side of point)") Date: Wed, 25 Oct 2017 19:11:37 +0000 Message-ID: <20171025191137.GA16060@ACM> References: <83lgkcgzs9.fsf@gnu.org> <20171022201340.GA16074@ACM> <834lqoa9jj.fsf@gnu.org> <20171024203312.GA5875@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1508959116 13658 195.159.176.226 (25 Oct 2017 19:18:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 25 Oct 2017 19:18:36 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: 28850@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 25 21:18:29 2017 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 1e7RBt-0001DK-Fa for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Oct 2017 21:18:13 +0200 Original-Received: from localhost ([::1]:49715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7RC0-0005Jc-JF for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Oct 2017 15:18:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7RBm-0005I4-8f for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 15:18:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7RBj-0004YX-2l for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 15:18:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53216) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7RBi-0004Xr-UK for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 15:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e7RBi-0002QJ-6L for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 15:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Oct 2017 19:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28850 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28850-submit@debbugs.gnu.org id=B28850.15089590279248 (code B ref 28850); Wed, 25 Oct 2017 19:18:02 +0000 Original-Received: (at 28850) by debbugs.gnu.org; 25 Oct 2017 19:17:07 +0000 Original-Received: from localhost ([127.0.0.1]:33664 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e7RAp-0002P5-F5 for submit@debbugs.gnu.org; Wed, 25 Oct 2017 15:17:07 -0400 Original-Received: from ocolin.muc.de ([193.149.48.4]:35689 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1e7RAm-0002Or-Re for 28850@debbugs.gnu.org; Wed, 25 Oct 2017 15:17:06 -0400 Original-Received: (qmail 64835 invoked by uid 3782); 25 Oct 2017 19:16:59 -0000 Original-Received: from acm.muc.de (p548C736A.dip0.t-ipconnect.de [84.140.115.106]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 25 Oct 2017 21:16:58 +0200 Original-Received: (qmail 16090 invoked by uid 1000); 25 Oct 2017 19:11:37 -0000 Content-Disposition: inline In-Reply-To: <20171024203312.GA5875@ACM> 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:138981 Archived-At: Hello again, Eli. On Tue, Oct 24, 2017 at 20:33:12 +0000, Alan Mackenzie wrote: > On Tue, Oct 24, 2017 at 17:46:08 +0300, Eli Zaretskii wrote: > > > Date: Sun, 22 Oct 2017 20:13:40 +0000 > > > Cc: 28850@debbugs.gnu.org > > > From: Alan Mackenzie [ .... ] > > Thanks, this fixes a very large part of the problem, so I think you > > should install this on the release branch. DONE. > > It doesn't solve all of it, though, because I got that breakpoint hit > > again. This time it took much longer before that happened (a sign > > that most of the problem is indeed solved), and the backtrace is > > different. > This is an entirely separate bug. > > Here's the C and the Lisp backtraces, followed by some relevant > > values: > [ .... ]. > > Lisp Backtrace: > > "re-search-forward" (0x88c050) > > 0xad7f328 PVEC_COMPILED > > "font-lock-fontify-keywords-region" (0x88ca70) > > "font-lock-default-fontify-region" (0x88ce60) > > "c-font-lock-fontify-region" (0x88d230) > > "font-lock-fontify-region" (0x88d578) > > 0x13810840 PVEC_COMPILED > > "run-hook-wrapped" (0x88daf0) > > "jit-lock--run-functions" (0x88dee0) > > "jit-lock-fontify-now" (0x88e3e0) > > "jit-lock-stealth-fontify" (0x88e9d0) > > "apply" (0x88e9c8) > > "timer-event-handler" (0x88edb8) > > (gdb) pp current_buffer->name_ > > "platform.h" > > (gdb) pp current_buffer->directory_ > > "d:/utils/lz4-1.7.5/programs/" > > (gdb) p PT > > $1 = 2645 > > (gdb) p bound > > $2 = make_number(2425) > > (gdb) up > > #1 0x011cd2c9 in Fre_search_forward (regexp=XIL(0x800000000adcb1f0), > > bound=..., noerror=..., count=...) at search.c:2271 > > 2271 return search_command (regexp, bound, noerror, count, 1, 1, 0); > > (gdb) pp regexp > > "\\(\\=\\|\\(\\=\\|[^\\]\\)[ > > ]\\)\\s *#\\s *\\(\\(?:\\(?:el\\)?if\\)\\)\\([^[:alnum:]_$]\\|$\\)\\(\\\\\\(.\\| > > [ > > ]\\)\\|[^ > > ]\\)*" > I've tracked down that regexp. It matches "#if" or "#elif" inside > macros. It's used in c-cpp-matchers in cc-fonts.el. > > As you see, point is at 2645, whereas BOUND is at 2425. This happens > > in the file platform.h from the lz4-1.7.5 distribution. Here's the > > relevant part of platform.h with the two locations shown (I added an > > empty line for each "^" marker): > The reason for this is that a generated lambda form with the argument > LIMIT (which would be the end of a jit-lock chunk or similar) internally > binds LIMIT to the end of the current macro. Inside this binding, which > searches for "defined" repeatedly, we go forward to after the last > "defined", as indicated in your source excerpt below. Unfortunately, > this point is beyond the original LIMIT supplied to the lambda, so in the > next re-search-forward, point is the wrong side of this original LIMIT. > This particular bit of CC Mode is "write only" code, and it could take > me some while to disentangle the stack of macros and function generators > which has produced it. I think I'm going to extract this form and > rewrite it more by hand, making it simpler to debug in the future. Actually, it wasn't that difficult to amend that form generator. Would you please try out the patch below, which should apply cleanly to master. > > /* ************************************** > > * Detect 64-bit OS > > * http://nadeausoftware.com/articles/2012/02/c_c_tip_how_detect_processor_type_using_compiler_predefined_macros > > ****************************************/ > > #if defined __ia64 || defined _M_IA64 /* Intel Itanium */ \ > > || defined __powerpc64__ || defined __ppc64__ || defined __PPC64__ /* POWER 64-bit */ \ > > || (defined __sparc && (defined __sparcv9 || defined __sparc_v9__ || defined __arch64__)) || defined __sparc64__ /* SPARC 64-bit */ \ > > || defined __x86_64__s || defined _M_X64 /* x86 64-bit */ \ > > || defined __arm64__ || defined __aarch64__ || defined __ARM64_ARCH_8__ /* ARM 64-bit */ \ > > || (defined __mips && (__mips == 64 || __mips == 4 || __mips == 3)) /* MIPS 64-bit */ \ > > ^ > > || defined _LP64 || defined __LP64__ /* NetBSD, OpenBSD */ || defined __64BIT__ /* AIX */ || defined _ADDR64 /* Cray */ \ > > || (defined __SIZEOF_POINTER__ && __SIZEOF_POINTER__ == 8) /* gcc */ > > ^ > > # if !defined(__64BIT__) > > # define __64BIT__ 1 > > # endif > > #endif > > As you see, BOUND is after the closing paren, after "3))", and point > > is at the beginning of "__SIZEOF_POINTER__" a couple of lines further. > Yes. BOUND would have been the end of a jit-lock-chunk. [ .... ] diff -r c2f277772ea2 cc-fonts.el --- a/cc-fonts.el Wed Oct 25 18:00:13 2017 +0000 +++ b/cc-fonts.el Wed Oct 25 18:57:20 2017 +0000 @@ -286,12 +286,17 @@ nil))))) res)))) - (defun c-make-font-lock-search-form (regexp highlights) + (defun c-make-font-lock-search-form (regexp highlights &optional check-point) ;; Return a lisp form which will fontify every occurrence of REGEXP ;; (a regular expression, NOT a function) between POINT and `limit' ;; with HIGHLIGHTS, a list of highlighters as specified on page - ;; "Search-based Fontification" in the elisp manual. - `(while (re-search-forward ,regexp limit t) + ;; "Search-based Fontification" in the elisp manual. If CHECK-POINT + ;; is non-nil, we will check (< (point) limit) in the main loop. + `(while + ,(if check-point + `(and (< (point) limit) + (re-search-forward ,regexp limit t)) + `(re-search-forward ,regexp limit t)) (unless (progn (goto-char (match-beginning 0)) (c-skip-comments-and-strings limit)) @@ -470,7 +475,9 @@ ,(c-make-font-lock-search-form regexp highlights))))) state-stanzas) - ,(c-make-font-lock-search-form (car normal) (cdr normal)) + ;; In the next form, check that point hasn't been moved beyond + ;; `limit' in any of the above stanzas. + ,(c-make-font-lock-search-form (car normal) (cdr normal) t) nil)))) ; (eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el. -- Alan Mackenzie (Nuremberg, Germany).