GNU bug report logs - #13542
24.3.50; args-out-of-range in jit-lock-fontify-now

Previous Next

Package: emacs;

Reported by: Aaron Ecay <aaronecay <at> gmail.com>

Date: Thu, 24 Jan 2013 19:28:02 UTC

Severity: normal

Found in version 24.3.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13542 in the body.
You can then email your comments to 13542 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#13542; Package emacs. (Thu, 24 Jan 2013 19:28:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Aaron Ecay <aaronecay <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 24 Jan 2013 19:28:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Aaron Ecay <aaronecay <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; args-out-of-range in jit-lock-fontify-now
Date: Thu, 24 Jan 2013 14:27:32 -0500
Related to the recent change to raise (as opposed to ignoring) errors
generated in timers, I have started seeing backtraces similar to the
following:

Debugger entered--Lisp error: (args-out-of-range 1 23)
  text-property-any(1 23 fontified t)
  jit-lock-fontify-now(1 501)
  jit-lock-stealth-fontify(t)
  apply(jit-lock-stealth-fontify t)
  byte-code("r\301^H\302H^H\303H\"\210)\301\207" [timer apply 5 6] 4)
  timer-event-handler([t 0 7 37086 nil jit-lock-stealth-fontify (t) idle
  943000])

This shows up (for example) in a message-mode buffer with some of the mail
headers hidden by narrowing.

The issue is that the min value for the region to be fontified is
calculated with the buffer temporarily widened (by the function
‘jit-lock-stealth-chunk-start’), but ‘jit-lock-fontify-now’ does not
widen the buffer.

I think the solution is either:
1) add a (save-restriction (widen) ...) to jit-lock-fontify-now*
2) add (setq start (max start (point-min))) at line 357 of jit-lock.el

I don’t know enough about the fontification code to know which is
correct.  (But note that strategy 2 is used for the ‘end’ argument to
‘jit-lock-fontify-now’, also at line 357).

* If widening should be done in general when fontifying, perhaps the
‘with-buffer-prepared-for-jit-lock’ macro should do it.

Thanks,

-- 
Aaron Ecay




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13542; Package emacs. (Wed, 30 Jan 2013 17:07:01 GMT) Full text and rfc822 format available.

Message #8 received at 13542 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Aaron Ecay <aaronecay <at> gmail.com>
Cc: 13542 <at> debbugs.gnu.org
Subject: Re: bug#13542: 24.3.50; args-out-of-range in jit-lock-fontify-now
Date: Wed, 30 Jan 2013 12:06:05 -0500
> The issue is that the min value for the region to be fontified is
> calculated with the buffer temporarily widened (by the function
> ‘jit-lock-stealth-chunk-start’), but ‘jit-lock-fontify-now’ does not
> widen the buffer.

That's a left over from the 2002-10-01 change that decided that jit-lock
should not widen.  I've installed the patch below which should fix
the problem.


        Stefan


=== modified file 'lisp/jit-lock.el'
--- lisp/jit-lock.el	2013-01-13 01:23:48 +0000
+++ lisp/jit-lock.el	2013-01-30 16:59:53 +0000
@@ -439,8 +435,6 @@
 Value is nil if there is nothing more to fontify."
   (if (zerop (buffer-size))
       nil
-    (save-restriction
-      (widen)
       (let* ((next (text-property-not-all around (point-max) 'fontified t))
 	     (prev (previous-single-property-change around 'fontified))
 	     (prop (get-text-property (max (point-min) (1- around))
@@ -473,7 +467,7 @@
 			   ((null next) start)
 			   ((< (- around start) (- next around)) start)
 			   (t next))))
-	result))))
+      result)))
 
 (defun jit-lock-stealth-fontify (&optional repeat)
   "Fontify buffers stealthily.
@@ -564,6 +558,8 @@
 	(when jit-lock-context-unfontify-pos
 	  ;; (message "Jit-Context %s" (buffer-name))
 	  (save-restriction
+            ;; Don't be blindsided by narrowing that starts in the middle
+            ;; of a jit-lock-defer-multiline.
 	    (widen)
 	    (when (and (>= jit-lock-context-unfontify-pos (point-min))
 		       (< jit-lock-context-unfontify-pos (point-max)))





bug closed, send any further explanations to 13542 <at> debbugs.gnu.org and Aaron Ecay <aaronecay <at> gmail.com> Request was from Stefan Monnier <monnier <at> iro.umontreal.ca> to control <at> debbugs.gnu.org. (Wed, 30 Jan 2013 17:08:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 28 Feb 2013 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 176 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.