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: 11841@debbugs.gnu.org, Vadim K <vadimsks@gmail.com>
Subject: bug#11841: 24.1; emacs hangs when opening cpp file with mixed eol styles
Date: Fri, 20 Jul 2012 21:10:46 +0000	[thread overview]
Message-ID: <20120720211046.GA3822@acm.acm> (raw)
In-Reply-To: <83lij25d3w.fsf@gnu.org>

Hello, Eli and Vadim.

On Mon, Jul 02, 2012 at 07:42:11PM +0300, Eli Zaretskii wrote:
> > Date: Sun, 1 Jul 2012 20:51:43 -0400
> > From: Vadim K <vadimsks@gmail.com>

> > Emacs hangs forever with 100% cpu usage when I'm trying to open a
> > specific cpp file (see attached bad.cpp). The bad.cpp file has
> > Windows end of line style (0D 0A) everywhere except in the line next
> > to the last one.

> Inconsistent EOL format is not the problem, it is just the trigger.
> The problem seems to be that the C Mode is unable to process a buffer
> where some lines end in a ^M^J (a.k.a. CRLF) instead of a mere LF
> (newline).  To see that, make the EOL format of the test file
> consistently CRLF, then do this:

>   emacs -Q
>   M-x find-file-literally RET bad.cpp RET
>   M-x normal-mode

> Emacs will hang.

> I attached a debugger and produced the backtrace below.  By doing
> "finish" until it hanged, I found out that it infloops inside
> c-backward-sws.  HTH.


> Lisp Backtrace:
> "forward-comment" (0x8890b8)
> "c-backward-sws" (0x889318)
> "c-at-macro-vsemi-p" (0x889568)
> "byte-code" (0x889740)
> "c-crosses-statement-barrier-p" (0x889af8)
> "byte-code" (0x889ce0)
> "c-beginning-of-statement-1" (0x88a0e8)
> "byte-code" (0x88a2c0)
> "c-beginning-of-decl-1" (0x88a668)
> "c-font-lock-enclosing-decls" (0x88a8c8)
> "font-lock-fontify-keywords-region" (0x88ab38)
> "font-lock-default-fontify-region" (0x88ad98)
> "c-font-lock-fontify-region" (0x88aff8)
> "font-lock-fontify-region" (0x88b38c)
> "run-hook-with-args" (0x88b388)
> "byte-code" (0x88b560)
> "jit-lock-fontify-now" (0x88b968)
> "jit-lock-function" (0x88bcf4)

The following patch should, I hope, fix the problem.  Vadim, would you
try it out, please, and report back..


diff -r 1adcc48506f9 cc-engine.el
--- a/cc-engine.el	Sun Apr 22 09:42:29 2012 +0000
+++ b/cc-engine.el	Fri Jul 20 20:52:39 2012 +0000
@@ -1455,7 +1455,12 @@
 	    (not (bobp))
 
 	    (if (let (open-paren-in-column-0-is-defun-start)
-		  (forward-comment -1))
+		  (or (forward-comment -1)
+		      ;; Cope specifically with ^M^J here -
+		      ;; forward-comment gets stuck at ^Ms.
+		      (and (eq (char-before) ?\r)
+			   (progn (backward-char)
+				  (forward-comment -1)))))
 		(if (looking-at "\\*/")
 		    ;; Emacs <= 20 and XEmacs move back over the
 		    ;; closer of a block comment that lacks an opener.


-- 
Alan Mackenzie (Nuremberg, Germany).





  parent reply	other threads:[~2012-07-20 21:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-02  0:51 bug#11841: 24.1; emacs hangs when opening cpp file with mixed eol styles Vadim K
2012-07-02 16:42 ` Eli Zaretskii
2012-07-02 18:22   ` Stefan Monnier
2012-07-07 21:10   ` Alan Mackenzie
2012-07-07 21:53     ` Stefan Monnier
2012-07-08  2:58       ` Eli Zaretskii
2012-07-08 14:50         ` Stefan Monnier
2012-07-08 15:34           ` Alan Mackenzie
2012-07-08 23:07             ` Stefan Monnier
2012-07-15 17:02               ` Alan Mackenzie
2012-07-15 22:56                 ` Stefan Monnier
2012-07-20 21:10   ` Alan Mackenzie [this message]
2012-07-22  9:54     ` Stefan Monnier
2012-07-25 20:58     ` Vadim K
2012-12-11 19:24   ` 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=20120720211046.GA3822@acm.acm \
    --to=acm@muc.de \
    --cc=11841@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=vadimsks@gmail.com \
    /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).