unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: contovob@tcd.ie, 28850@debbugs.gnu.org
Subject: bug#28850: 26.0.90; Error running timer 'jit-lock-stealth-fontify': (error "Invalid search bound (wrong side of point)")
Date: Sat, 4 May 2019 12:41:02 +0000	[thread overview]
Message-ID: <20190504124102.GB4139@ACM> (raw)
In-Reply-To: <83y33qovrw.fsf@gnu.org>

Hello, Eli.

Sorry it's taken me a little time to answer you.  I was rather busy with
another bug.

On Wed, May 01, 2019 at 21:49:07 +0300, Eli Zaretskii wrote:
> > Date: Tue, 30 Apr 2019 18:26:26 +0300
> > From: Eli Zaretskii <eliz@gnu.org>
> > Cc: acm@muc.de, 28850@debbugs.gnu.org
> > 
> > FWIW, I think I see something similar in Emacs 26.2, I will try to
> > catch it one of these days.

> Done.  The error messages are slightly different: wrong-type-argument
> number-or-marker-p nil.

> It was very hard to debug, but eventually I succeeded to catch a
> backtrace:

>   Thread 1 hit Breakpoint 5, wrong_type_argument (predicate=XIL(0x9f90),
>       value=XIL(0)) at data.c:146
>   146     {
>   #0  wrong_type_argument (predicate=XIL(0x9f90), value=XIL(0)) at data.c:146
>   #1  0x01127519 in CHECK_TYPE (x=XIL(0), predicate=<optimized out>, ok=0)
>       at lisp.h:625

[ .... ]


>   Lisp Backtrace:
>   "1+" (0x88acd0)
>   "goto-char" (0x88adb8)
>   "save-excursion" (0x88aee8)
>   "cond" (0x88aff8)
>   "setq" (0x88b138)
>   "let" (0x88b2b8)
>   "if" (0x88b3d8)
>   "catch" (0x88b548)
>   "while" (0x88b668)
>   "if" (0x88b788)
>   "save-restriction" (0x88b8b8)
>   "let" (0x88baf8)
>   "c-beginning-of-statement-1" (0x88bbf0)
>   "setq" (0x88be48)
>   "eq" (0x88bf38)
>   "not" (0x88c028)
>   "and" (0x88c138)
>   "while" (0x88c258)
>   "let" (0x88c3d8)
>   "let*" (0x88c528)
>   "catch" (0x88c698)
>   "c-beginning-of-decl-1" (0x88c810)
>   0xadfab48 PVEC_COMPILED
>   "font-lock-fontify-keywords-region" (0x88d0c0)
>   "font-lock-default-fontify-region" (0x88d410)
>   "c-font-lock-fontify-region" (0x88d740)
>   "font-lock-fontify-region" (0x88d9e8)
>   0x18b47060 PVEC_COMPILED
>   "run-hook-wrapped" (0x88de00)
>   "jit-lock--run-functions" (0x88e150)
>   "jit-lock-fontify-now" (0x88e5b0)
>   "jit-lock-stealth-fontify" (0x88ea60)
>   "apply" (0x88ea58)
>   "timer-event-handler" (0x88eda8)

> This comes from the following code fragment:

>   (defun c-beginning-of-statement-1 (&optional lim ignore-labels
> 					       noerror comma-delim)
>   [...]
> 			   ;; Just gone back over some paren block?
> 			   ((looking-at "\\s(")
> 			    (save-excursion
> 			      (goto-char (1+ (c-down-list-backward
> 					      before-sws-pos)))
> 			      (c-crosses-statement-barrier-p
> 			       (point) maybe-after-boundary-pos)))

> c-down-list-backward is documented to be able to return nil, so
> passing the result to 1+ is unsafe.

The movement function which brought point to that "\\s(" was
c-backward-sexp, i.e. (goto-char (scan-sexps (point) -1)), so the nil
that you got from c-down-list-backward "can't possibly happen".  :-(

> I cannot claim a good understanding of the code, ....

Long ago, that function, before it was rewritten by Martin Stjernholm,
carried the comment "if you think you understand this function you are
probably mistaken." ;-).

> .... but the following ad-hoc patch fixes the problem for me:

> --- lisp/progmodes/cc-engine.el~0	2019-01-07 16:26:06.000000000 +0200
> +++ lisp/progmodes/cc-engine.el	2019-05-01 14:43:35.823456200 +0300
> @@ -1130,10 +1130,12 @@
>  			 ;; Just gone back over some paren block?
>  			 ((looking-at "\\s(")
>  			  (save-excursion
> -			    (goto-char (1+ (c-down-list-backward
> -					    before-sws-pos)))
> -			    (c-crosses-statement-barrier-p
> -			     (point) maybe-after-boundary-pos)))
> +			    (let ((pos1 (c-down-list-backward
> +					 before-sws-pos)))
> +			      (when (number-or-marker-p pos1)
> +				(goto-char (1+ pos1))
> +				(c-crosses-statement-barrier-p
> +				 (point) maybe-after-boundary-pos)))))
>  			 ;; Just gone back over an ordinary symbol of some sort?
>  			 (t (c-crosses-statement-barrier-p
>  			     (point) maybe-after-boundary-pos))))

However, that nil clearly did happen, so I'll be spending some time
working out how it could have happened, and amending
c-beginning-of-statement-1 accordingly, whether with your ad-hoc patch
or otherwise.

Thanks for taking so much time and trouble to get that stack trace.

-- 
Alan Mackenzie (Nuremberg, Germany).





  reply	other threads:[~2019-05-04 12:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-15 16:07 bug#28850: 26.0.90; Error running timer 'jit-lock-stealth-fontify': (error "Invalid search bound (wrong side of point)") Eli Zaretskii
2017-10-17 16:42 ` Alan Mackenzie
2017-10-22 20:13 ` Alan Mackenzie
2017-10-24 14:46   ` Eli Zaretskii
2017-10-24 20:33     ` Alan Mackenzie
2017-10-25 19:11       ` Alan Mackenzie
2017-10-26 16:44         ` Eli Zaretskii
2017-10-26 18:36           ` Alan Mackenzie
2019-04-30  1:51           ` Basil L. Contovounesios
2019-04-30  9:24             ` Alan Mackenzie
2019-04-30 11:33             ` Alan Mackenzie
2019-04-30 12:57               ` Basil L. Contovounesios
2019-04-30 13:32                 ` Alan Mackenzie
2019-04-30 13:44                   ` Basil L. Contovounesios
2019-04-30 15:35                     ` Eli Zaretskii
2019-04-30 15:50                       ` Alan Mackenzie
2019-05-06 18:44                     ` Alan Mackenzie
2019-05-07  0:35                       ` Basil L. Contovounesios
2019-04-30 15:30                   ` Eli Zaretskii
2019-04-30 15:43                     ` Alan Mackenzie
2019-04-30 15:26                 ` Eli Zaretskii
2019-05-01 18:49                   ` Eli Zaretskii
2019-05-04 12:41                     ` Alan Mackenzie [this message]
2019-05-04 13:36                       ` Eli Zaretskii
2019-05-05  9:06                         ` Alan Mackenzie
2019-05-06 15:35                           ` Eli Zaretskii
2019-05-06 18:10                             ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190504124102.GB4139@ACM \
    --to=acm@muc.de \
    --cc=28850@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).