GNU bug report logs - #7181
24.0.50; args-out-of-range while reverting C++ header file

Previous Next

Packages: emacs, cc-mode;

Reported by: ofv <at> wanadoo.es (Oscar Fuentes)

Date: Sat, 9 Oct 2010 04:28:01 UTC

Severity: normal

Found in version 24.0.50

Done: Glenn Morris <rgm <at> gnu.org>

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 7181 in the body.
You can then email your comments to 7181 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 owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7181; Package emacs. (Sat, 09 Oct 2010 04:28:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to ofv <at> wanadoo.es (Oscar Fuentes):
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 09 Oct 2010 04:28:02 GMT) Full text and rfc822 format available.

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

From: ofv <at> wanadoo.es (Oscar Fuentes)
To: bug-gnu-emacs <at> gnu.org
Cc: Alan Mackenzie <acm <at> muc.de>
Subject: 24.0.50; args-out-of-range while reverting C++ header file
Date: Sat, 09 Oct 2010 06:30:32 +0200
This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs <at> gnu.org mailing list,
and to the gnu.emacs.bug news group.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug.  If you can, give
a recipe starting from `emacs -Q':

emacs -Q
C-x C-f some-moderately-big-header-file.h
<make some big modification on disk to the file>
M-x revert-buffer
Lisp error: (args-out-of-range 580 36722)

The buffer is left semi-reverted, on an edited state. Doing a M-x
revert-buffer again works ok.

Setting debug-on-error to t shows this:

Debugger entered--Lisp error: (args-out-of-range 580 36722)
  remove-text-properties(580 36722 (category))
  c-clear-char-property-with-value-function(1 36722 category c-cpp-delimiter)
  c-neutralize-syntax-in-and-mark-CPP(174 174 36141)
  c-after-change(174 174 36141)
  insert-file-contents("/home/oscar/dev/idb/lp0/ffi.h" t nil nil t)
  revert-buffer(t)
  call-interactively(revert-buffer t nil)
  execute-extended-command(nil)
  call-interactively(execute-extended-command nil nil)

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/usr/local/share/emacs/24.0.50/etc/DEBUG.


In GNU Emacs 24.0.50.1 (x86_64-unknown-linux-gnu, X toolkit)
 of 2010-09-16 on qcore
Windowing system distributor `The X.Org Foundation', version 11.0.60900000
configured using `configure  '--without-toolkit-scroll-bars' '--with-x-toolkit=lucid''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: Debugger

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-x C-f f f i . h <return> M-x r e v e r t SPC b u 
f f e r <return> y e s <return> M-x <up> <return> y 
e s <return> SPC C-_ M-x s e t SPC v a r i <tab> <return> 
d e b u <tab> o n <tab> e r r <tab> <return> t <return> 
M-x r e v e r t SPC b u f f e r <return> y e s <return> 
M-x r e v e r t SPC b u f f e r <return> y e s <return> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> C-SPC 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> M-w <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <menu-bar> <help-menu> <se
nd-emacs-bug-report>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Loading vc-git...done
c-clear-char-property-with-value-function: Args out of range: 580, 36722
Undo!
Entering debugger...
Mark set

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr message sendmail rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mailabbrev mail-utils gmm-utils mailheader
emacsbug help-mode view debug cus-edit wid-edit cus-start cus-load
help-fns vc-git cc-mode cc-fonts easymenu cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs regexp-opt tooltip ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image
fringe lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev loaddefs button minibuffer faces cus-face files
text-properties overlay md5 base64 format env code-pages mule custom
widget hashtable-print-readable backquote make-network-process
dynamic-setting font-render-setting x-toolkit x multi-tty emacs)




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7181; Package emacs. (Sat, 09 Oct 2010 08:55:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: ofv <at> wanadoo.es (Oscar Fuentes)
Cc: 7181 <at> debbugs.gnu.org
Subject: Re: bug#7181: 24.0.50;
	args-out-of-range while reverting C++ header file
Date: Sat, 09 Oct 2010 10:57:53 +0200
> From: ofv <at> wanadoo.es (Oscar Fuentes)
> Date: Sat, 09 Oct 2010 06:30:32 +0200
> Cc: 
> 
> emacs -Q
> C-x C-f some-moderately-big-header-file.h
> <make some big modification on disk to the file>
> M-x revert-buffer
> Lisp error: (args-out-of-range 580 36722)
> 
> The buffer is left semi-reverted, on an edited state. Doing a M-x
> revert-buffer again works ok.
> 
> Setting debug-on-error to t shows this:
> 
> Debugger entered--Lisp error: (args-out-of-range 580 36722)
>   remove-text-properties(580 36722 (category))

Can you verify that the problem happens because one or both argument
positions of remove-text-properties don't exist due to the changes?




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7181; Package emacs. (Sat, 09 Oct 2010 13:36:02 GMT) Full text and rfc822 format available.

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

From: Óscar Fuentes <ofv <at> wanadoo.es>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Alan Mackenzie <acm <at> muc.de>, 7181 <at> debbugs.gnu.org
Subject: Re: bug#7181: 24.0.50;
	args-out-of-range while reverting C++ header file
Date: Sat, 09 Oct 2010 15:39:14 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> emacs -Q
>> C-x C-f some-moderately-big-header-file.h
>> <make some big modification on disk to the file>
>> M-x revert-buffer
>> Lisp error: (args-out-of-range 580 36722)
>> 
>> The buffer is left semi-reverted, on an edited state. Doing a M-x
>> revert-buffer again works ok.
>> 
>> Setting debug-on-error to t shows this:
>> 
>> Debugger entered--Lisp error: (args-out-of-range 580 36722)
>>   remove-text-properties(580 36722 (category))
>
> Can you verify that the problem happens because one or both argument
> positions of remove-text-properties don't exist due to the changes?

Essentially, the end position which is out of range corresponds to the
size of the *previous* contents of the file, not of the current
file. For instance:

While visiting file ffi.h with size 26675, replace it on disk with
another version of 36721 bytes, revert-buffer, (args-out-of-range 580
26676).

If we are visiting the long version of ffi.h (the one with 36721 bytes)
and replace it on disk with the short version, then (args-out-of-range
580 36722).

On both cases the buffer is left with 580 bytes of content, part of them
belonging to the beginning of the file and the other part to the end of
the file. The first byte missing from the buffer after revert-buffer
fails is the first character which differs from one version to another
of the file.

I'll try to reduce a test case file.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7181; Package emacs. (Sat, 09 Oct 2010 13:54:02 GMT) Full text and rfc822 format available.

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

From: Óscar Fuentes <ofv <at> wanadoo.es>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 7181 <at> debbugs.gnu.org
Subject: Re: bug#7181: 24.0.50;
	args-out-of-range while reverting C++ header file
Date: Sat, 09 Oct 2010 15:56:39 +0200
[Message part 1 (text/plain, inline)]
With the attached files the problem can be reproduced predictability:

Save the attached files b.h.master and b.h.next to a directory and cd to
it.

$ emacs -Q &
$ cp b.h.master b.h
C-x C-f b.h
$ cp b.h.next b.h
M-x revert-buffer

and the args-out-of-range error pops:

c-clear-char-property-with-value-function: Args out of range: 166, 453

I was unable to try with the latest Emacs sources because the build is
broken. My Emacs is from the 16 September.

[b.h.master (application/octet-stream, attachment)]
[b.h.next (application/octet-stream, attachment)]

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7181; Package emacs. (Sat, 09 Oct 2010 20:58:01 GMT) Full text and rfc822 format available.

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

From: Alan Mackenzie <acm <at> muc.de>
To: Óscar Fuentes <ofv <at> wanadoo.es>
Cc: 7181 <at> debbugs.gnu.org, emacs-devel <at> gnu.org
Subject: Re: bug#7181: 24.0.50;
	args-out-of-range while reverting C++ header file
Date: Sat, 9 Oct 2010 21:13:32 +0000
Hi, Óscar,

On Sat, Oct 09, 2010 at 03:56:39PM +0200, Óscar Fuentes wrote:
> With the attached files the problem can be reproduced predictability:
> 
> Save the attached files b.h.master and b.h.next to a directory and cd to
> it.
> 
> $ emacs -Q &
> $ cp b.h.master b.h
> C-x C-f b.h
> $ cp b.h.next b.h
> M-x revert-buffer
> 
> and the args-out-of-range error pops:
> 
> c-clear-char-property-with-value-function: Args out of range: 166, 453
> 
> I was unable to try with the latest Emacs sources because the build is
> broken. My Emacs is from the 16 September.
> 

Thanks for the recipe.  I turned on debug-on-error and got this
traceback:

Debugger entered--Lisp error: (args-out-of-range 166 453)
  remove-text-properties(166 453 (category))
  c-clear-char-property-with-value-function(1 453 category c-cpp-delimiter)
  c-neutralize-syntax-in-and-mark-CPP(94 94 286)
  c-after-change(94 94 286) <<======================================
  insert-file-contents("/home/acm/b.h" t nil nil t)
  revert-buffer(t)
  call-interactively(revert-buffer nil nil)

c-after-change is on the after-change-functions hook.  The values of BEG
END OLD-LEN it is being passed look utterly wrong.  BEG and END should
delimit the entire buffer and OLD-LEN should be the length of the
previous buffer.  Surely?

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#7181; Package emacs,cc-mode. (Sat, 09 Oct 2010 22:06:01 GMT) Full text and rfc822 format available.

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

From: Óscar Fuentes <ofv <at> wanadoo.es>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 7181 <at> debbugs.gnu.org, emacs-devel <at> gnu.org
Subject: after-change-functions hook arguments (was: bug#7181: 24.0.50;
	args-out-of-range while reverting C++ header file)
Date: Sun, 10 Oct 2010 00:08:22 +0200
Alan Mackenzie <acm <at> muc.de> writes:

> Thanks for the recipe.  I turned on debug-on-error and got this
> traceback:
>
> Debugger entered--Lisp error: (args-out-of-range 166 453)
>   remove-text-properties(166 453 (category))
>   c-clear-char-property-with-value-function(1 453 category c-cpp-delimiter)
>   c-neutralize-syntax-in-and-mark-CPP(94 94 286)
>   c-after-change(94 94 286) <<======================================
>   insert-file-contents("/home/acm/b.h" t nil nil t)
>   revert-buffer(t)
>   call-interactively(revert-buffer nil nil)
>
> c-after-change is on the after-change-functions hook.  The values of BEG
> END OLD-LEN it is being passed look utterly wrong.  BEG and END should
> delimit the entire buffer and OLD-LEN should be the length of the
> previous buffer.  Surely?

Seems that insert-file-contents is trying to be smart and determine
which parts of the contents are shared among the old and the new
text. On this case b.h.next and b.h.master differ only on the central
region of text. The arguments passed to c-after-change indicates a
deletion from position 94 to position 94+286=380.

I don't know if that is correct, as the transformation is not a deletion
but a replacement of the middle text segment of the buffer with a text
chunk of different lenght, and the doc is not clear about that case.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#7181; Package emacs,cc-mode. (Sat, 09 Oct 2010 23:30:04 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Óscar Fuentes <ofv <at> wanadoo.es>, 7181 <at> debbugs.gnu.org,
	emacs-devel <at> gnu.org
Subject: Re: bug#7181: 24.0.50;
	args-out-of-range while reverting C++ header file
Date: Sun, 10 Oct 2010 01:33:19 +0200
>> With the attached files the problem can be reproduced predictability:
>> 
>> Save the attached files b.h.master and b.h.next to a directory and cd to
>> it.
>> 
>> $ emacs -Q &
>> $ cp b.h.master b.h
>> C-x C-f b.h
>> $ cp b.h.next b.h
>> M-x revert-buffer
>> 
>> and the args-out-of-range error pops:
>> 
>> c-clear-char-property-with-value-function: Args out of range: 166, 453
>> 
>> I was unable to try with the latest Emacs sources because the build is
>> broken. My Emacs is from the 16 September.
>> 

> Thanks for the recipe.  I turned on debug-on-error and got this
> traceback:

> Debugger entered--Lisp error: (args-out-of-range 166 453)
>   remove-text-properties(166 453 (category))
>   c-clear-char-property-with-value-function(1 453 category c-cpp-delimiter)
>   c-neutralize-syntax-in-and-mark-CPP(94 94 286)
>   c-after-change(94 94 286) <<======================================
>   insert-file-contents("/home/acm/b.h" t nil nil t)
>   revert-buffer(t)
>   call-interactively(revert-buffer nil nil)

> c-after-change is on the after-change-functions hook.  The values of BEG
> END OLD-LEN it is being passed look utterly wrong.  BEG and END should
> delimit the entire buffer and OLD-LEN should be the length of the
> previous buffer.  Surely?

No, here the after-change is called right after removing the chars that
are different, and just before inserting the new (different) chars.
You can reproduce the same error without reverting:

emacs -Q b.h.master
M-x c-mode
C-u 93 C-f
C-SPC
C-u 286 C-f
C-w


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#7181; Package emacs,cc-mode. (Sun, 10 Oct 2010 13:54:02 GMT) Full text and rfc822 format available.

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

From: Alan Mackenzie <acm <at> muc.de>
To: Óscar Fuentes <ofv <at> wanadoo.es>
Cc: 7181 <at> debbugs.gnu.org
Subject: Re: bug#7181: 24.0.50;
	args-out-of-range while reverting C++ header file.  PATCH.
Date: Sun, 10 Oct 2010 14:09:58 +0000
Hi, Óscar,

On Sat, Oct 09, 2010 at 03:56:39PM +0200, Óscar Fuentes wrote:
> With the attached files the problem can be reproduced predictability:
> 
> Save the attached files b.h.master and b.h.next to a directory and cd to
> it.
> 
> $ emacs -Q &
> $ cp b.h.master b.h
> C-x C-f b.h
> $ cp b.h.next b.h
> M-x revert-buffer
> 
> and the args-out-of-range error pops:
> 
> c-clear-char-property-with-value-function: Args out of range: 166, 453
> 
> I was unable to try with the latest Emacs sources because the build is
> broken. My Emacs is from the 16 September.
> 

Please try the following patch and confirm that it works.  I'll get it
committed just as soon as I manage to connect to the new server:




*** cc-mode.el.~3~	2010-10-08 20:27:13.000000000 +0000
--- cc-mode.el	2010-10-10 13:46:28.074200752 +0000
***************
*** 1029,1038 ****
  			    (buffer-substring-no-properties type-pos term-pos)
  			    (buffer-substring-no-properties beg end)))))))
  
- 	;; (c-new-BEG c-new-END) will be the region to fontify.  It may become
- 	;; larger than (beg end).
- 	(setq c-new-BEG beg
- 	      c-new-END end)
  	(if c-get-state-before-change-functions
  	    (mapc (lambda (fn)
  		    (funcall fn beg end))
--- 1029,1034 ----
***************
*** 1086,1091 ****
--- 1082,1091 ----
  	(when c-recognize-<>-arglists
  	  (c-after-change-check-<>-operators beg end))
  
+ 	;; (c-new-BEG c-new-END) will be the region to fontify.  It may become
+ 	;; larger than (beg end).
+ 	(setq c-new-BEG beg
+ 	      c-new-END end)
  	(if c-before-font-lock-function
  	    (save-excursion
  	      (funcall c-before-font-lock-function beg end old-len)))))))

      

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#7181; Package emacs,cc-mode. (Sun, 10 Oct 2010 18:38:02 GMT) Full text and rfc822 format available.

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

From: Óscar Fuentes <ofv <at> wanadoo.es>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 7181 <at> debbugs.gnu.org
Subject: Re: bug#7181: 24.0.50;
	args-out-of-range while reverting C++ header file.  PATCH.
Date: Sun, 10 Oct 2010 20:40:51 +0200
Alan Mackenzie <acm <at> muc.de> writes:

> Please try the following patch and confirm that it works.  I'll get it
> committed just as soon as I manage to connect to the new server:

[snip]

Yep, the error is gone. Thank you, Alan.





bug closed, send any further explanations to ofv <at> wanadoo.es (Oscar Fuentes) Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 21 Oct 2010 17:36:01 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. (Fri, 19 Nov 2010 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 274 days ago.

Previous Next


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