GNU bug report logs - #10941
[24.0.93.3] cc-mode: error in message buffer when "typing fast", characters eaten

Previous Next

Packages: emacs, cc-mode;

Reported by: Paul Pogonyshev <pogonyshev <at> gmx.net>

Date: Sun, 4 Mar 2012 18:17:01 UTC

Severity: normal

Done: Alan Mackenzie <acm <at> muc.de>

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 10941 in the body.
You can then email your comments to 10941 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#10941; Package emacs. (Sun, 04 Mar 2012 18:17:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Pogonyshev <pogonyshev <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 04 Mar 2012 18:17:02 GMT) Full text and rfc822 format available.

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

From: Paul Pogonyshev <pogonyshev <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: [24.0.93.3] cc-mode: error in message buffer when "typing fast",
	characters eaten
Date: Sun, 4 Mar 2012 21:14:43 +0300
[Message part 1 (text/plain, inline)]
Sometimes (quite often) when opening a different syntax region --- a
quoted string, or block comment --- in C++ mode, the first character
after it gets eaten with some error message shown in the echo area.  I
managed to create a surefire (at least here) way to reproduce it.

* save the attached file as 'test.cpp' (it is quite large, but when I
  tried to shorten it substantially, error disappeared);

* start Emacs as 'emacs -Q test.cpp';

* issue Elisp command right at the start of the buffer with M-: (this
  emulates fast typing):

      (progn (insert "/*") (insert " "))

  note that two separate inserts are essential, with one "/* " error
  is not triggered;

* observer the following error:

      Debugger entered--Lisp error: (error "Invalid search bound
      (wrong side of point)")

Full Emacs version: GNU Emacs 24.0.93.3 (x86_64-unknown-linux-gnu,
GTK+ Version 2.24.10) of 2012-02-25 on gonzo

Paul
[test.cpp (text/x-c++src, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#10941; Package emacs,cc-mode. (Thu, 29 Mar 2012 22:22:02 GMT) Full text and rfc822 format available.

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

From: Alan Mackenzie <acm <at> muc.de>
To: Paul Pogonyshev <pogonyshev <at> gmx.net>, 10941 <at> debbugs.gnu.org
Subject: bug#10941: [24.0.93.3] cc-mode: error in message buffer when "typing
	fast", characters eaten
Date: Thu, 29 Mar 2012 21:48:51 +0000
Hi, Paul.

Thanks for this report.  I can reproduce the error.  However, looking at
the code, it "can't possibly happen".  :-(  A few questions:

> Sometimes (quite often) when opening a different syntax region --- a
> quoted string, or block comment --- in C++ mode, the first character
> after it gets eaten with some error message shown in the echo area.  I
> managed to create a surefire (at least here) way to reproduce it.

What exactly do you mean by "opening a different syntax region"?  Do you
mean moving point into it, or scrolling to see it?

> * save the attached file as 'test.cpp' (it is quite large, but when I
>   tried to shorten it substantially, error disappeared);

Aha!  It's 3991 bytes long.  I'm going to try a binary chop on the
length.  I have a strange feeling the threshold length of the file
(before insertion of "/* ") will be 2048.

> * start Emacs as 'emacs -Q test.cpp';

> * issue Elisp command right at the start of the buffer with M-: (this
>   emulates fast typing):

>       (progn (insert "/*") (insert " "))

>   note that two separate inserts are essential, with one "/* " error
>   is not triggered;

OK.  I have a suspicion it could be something like two
before-change-functions being invoked without the after-change-function
which should come between them.

Strangely, though, once this error has happened, it doesn't happen again
in the same Emacs session, even if the buffer is killed and the file
reloaded.

> * observer the following error:

>       Debugger entered--Lisp error: (error "Invalid search bound
>       (wrong side of point)")

> Full Emacs version: GNU Emacs 24.0.93.3 (x86_64-unknown-linux-gnu,
> GTK+ Version 2.24.10) of 2012-02-25 on gonzo

Paul

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#10941; Package emacs,cc-mode. (Thu, 29 Mar 2012 22:44:02 GMT) Full text and rfc822 format available.

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

From: Paul Pogonyshev <pogonyshev <at> gmx.net>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 10941 <at> debbugs.gnu.org
Subject: Re: bug#10941: [24.0.93.3] cc-mode: error in message buffer when
	"typing fast", characters eaten
Date: Fri, 30 Mar 2012 01:11:05 +0300
Alan Mackenzie wrote:
> > Sometimes (quite often) when opening a different syntax region --- a
> > quoted string, or block comment --- in C++ mode, the first character
> > after it gets eaten with some error message shown in the echo area.  I
> > managed to create a surefire (at least here) way to reproduce it.
> 
> What exactly do you mean by "opening a different syntax region"?  Do you
> mean moving point into it, or scrolling to see it?

Just typing, similarly to the testcase.  When you quickly type an
opening quote (") or inline comment starter (/*) and then instantly
continue typing whatever is going to be inside, this error happens.
Far from always, but often enough to be annoying.

> OK.  I have a suspicion it could be something like two
> before-change-functions being invoked without the after-change-function
> which should come between them.

I have a different suspicion that sometimes cc-mode relies on data
found in font-lock only and that data may or may not be present (or up
to date) depending on how fast lazy font-locking happens.  But of
course you know the code better to decide if that is possible at all.

Paul




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#10941; Package emacs,cc-mode. (Fri, 30 Mar 2012 22:21:01 GMT) Full text and rfc822 format available.

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

From: Alan Mackenzie <acm <at> muc.de>
To: Paul Pogonyshev <pogonyshev <at> gmx.net>
Cc: 10941 <at> debbugs.gnu.org
Subject: Re: bug#10941: [24.0.93.3] cc-mode: error in message buffer when
	"typing fast", characters eaten
Date: Fri, 30 Mar 2012 22:19:21 +0000
Hello, Paul.

On Fri, Mar 30, 2012 at 01:11:05AM +0300, Paul Pogonyshev wrote:
> Alan Mackenzie wrote:
> > > Sometimes (quite often) when opening a different syntax region --- a
> > > quoted string, or block comment --- in C++ mode, the first character
> > > after it gets eaten with some error message shown in the echo area.  I
> > > managed to create a surefire (at least here) way to reproduce it.

> > What exactly do you mean by "opening a different syntax region"?  Do you
> > mean moving point into it, or scrolling to see it?

> Just typing, similarly to the testcase.  When you quickly type an
> opening quote (") or inline comment starter (/*) and then instantly
> continue typing whatever is going to be inside, this error happens.
> Far from always, but often enough to be annoying.

Thanks for the description.

I think I've found the trouble.  It was a simple mistake in calculating a
search limit.  I don't understand how this only bites when the buffer is
newly loaded, but whatever.

Would you please try out this patch and let me know whether it solves the
problem.


diff -r 002a49d7b836 cc-engine.el
--- a/cc-engine.el	Fri Mar 16 13:14:22 2012 +0000
+++ b/cc-engine.el	Fri Mar 30 22:13:40 2012 +0000
@@ -5414,7 +5414,7 @@
 	  new-beg new-end need-new-beg need-new-end)
       ;; Locate the barrier before the changed region
       (goto-char  (if beg-lit-limits (car beg-lit-limits) beg))
-      (c-syntactic-skip-backward "^;{}" (max (- beg 2048) (point-min)))
+      (c-syntactic-skip-backward "^;{}" (c-determine-limit 512))
       (setq new-beg (point))
 
       ;; Remove the syntax-table/category properties from each pertinent <...>
@@ -5426,8 +5426,7 @@
 
       ;; Locate the barrier after END.
       (goto-char (if end-lit-limits (cdr end-lit-limits) end))
-      (c-syntactic-re-search-forward "[;{}]"
-				     (min (+ end 2048) (point-max)) 'end)
+      (c-syntactic-re-search-forward "[;{}]" (c-determine-+ve-limit 512) 'end)
       (setq new-end (point))
 
       ;; Remove syntax-table properties from the remaining pertinent <...>

> Paul

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#10941; Package emacs,cc-mode. (Sat, 31 Mar 2012 20:28:02 GMT) Full text and rfc822 format available.

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

From: Paul Pogonyshev <pogonyshev <at> gmx.net>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 10941 <at> debbugs.gnu.org
Subject: Re: bug#10941: [24.0.93.3] cc-mode: error in message buffer when
	"typing fast", characters eaten
Date: Sat, 31 Mar 2012 23:27:14 +0300
Alan Mackenzie wrote:
> Would you please try out this patch and let me know whether it solves the
> problem.

Sorry, I can't because that'd require a lot of coding (the bug is not
deterministic) to see if the problem is gone and I don't code
currently.  Just commit it and close the bug as long as it solves the
original testcase.

Paul




Reply sent to Alan Mackenzie <acm <at> muc.de>:
You have taken responsibility. (Wed, 11 Apr 2012 18:22:02 GMT) Full text and rfc822 format available.

Notification sent to Paul Pogonyshev <pogonyshev <at> gmx.net>:
bug acknowledged by developer. (Wed, 11 Apr 2012 18:22:02 GMT) Full text and rfc822 format available.

Message #22 received at 10941-done <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: 10941-done <at> debbugs.gnu.org
Subject: Re: bug#10941: [24.0.93.3] cc-mode: error in message buffer when
	"typing fast", characters eaten
Date: Wed, 11 Apr 2012 18:19:09 +0000
(At least partially) fixed.

-- 
Alan Mackenzie (Nuremberg, Germany).




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

This bug report was last modified 13 years and 126 days ago.

Previous Next


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