From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#18022: 24.3; Emacs hard locks when attempting to do a replacement with ^M in it. Date: Sat, 19 Jul 2014 20:33:10 +0000 Message-ID: <20140719203310.GA12706@acm.acm> References: <83ha2i901p.fsf@gnu.org> <8338e28t9r.fsf@gnu.org> <20140716214144.GA4052@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1405802380 21187 80.91.229.3 (19 Jul 2014 20:39:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Jul 2014 20:39:40 +0000 (UTC) Cc: Marty Rosenberg , 18022@debbugs.gnu.org To: Stefan Monnier , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 19 22:39:32 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X8bPn-0000TE-BD for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Jul 2014 22:39:31 +0200 Original-Received: from localhost ([::1]:55502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8bPm-0004hR-Vd for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Jul 2014 16:39:30 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8bPc-0004eC-Sb for bug-gnu-emacs@gnu.org; Sat, 19 Jul 2014 16:39:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X8bPV-0002pG-BR for bug-gnu-emacs@gnu.org; Sat, 19 Jul 2014 16:39:20 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36214) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8bPL-0002nf-Gn; Sat, 19 Jul 2014 16:39:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1X8bPK-00032n-Tn; Sat, 19 Jul 2014 16:39:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sat, 19 Jul 2014 20:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18022 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 18022-submit@debbugs.gnu.org id=B18022.140580228611606 (code B ref 18022); Sat, 19 Jul 2014 20:39:02 +0000 Original-Received: (at 18022) by debbugs.gnu.org; 19 Jul 2014 20:38:06 +0000 Original-Received: from localhost ([127.0.0.1]:59713 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X8bOP-000317-4s for submit@debbugs.gnu.org; Sat, 19 Jul 2014 16:38:05 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:49664 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X8bOK-00030e-SW for 18022@debbugs.gnu.org; Sat, 19 Jul 2014 16:38:01 -0400 Original-Received: (qmail 34547 invoked by uid 3782); 19 Jul 2014 20:37:59 -0000 Original-Received: from acm.muc.de (pD9519715.dip0.t-ipconnect.de [217.81.151.21]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 19 Jul 2014 22:37:57 +0200 Original-Received: (qmail 12912 invoked by uid 1000); 19 Jul 2014 20:33:10 -0000 Content-Disposition: inline In-Reply-To: <20140716214144.GA4052@acm.acm> User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:91672 Archived-At: Hello, Stefan, Marty and Eli. On Wed, Jul 16, 2014 at 09:41:44PM +0000, Alan Mackenzie wrote: > On Tue, Jul 15, 2014 at 07:46:08PM +0300, Eli Zaretskii wrote: > > Alan, can you take a look? > OK, I've made some progress. Just to be specific what the problem is: > When in 64-bit Gnu/Linux, a C++ file is exactly this (where ^M is a > carriage return) > template ^MSimulatorBase::foobar() > (there being no newline at EOB), font-locking hangs, though hitting a > frame changing command followed by C-g often enough will switch frames. OK. The problem is in forward-comment. If you put point on the S after the ^M and do M-: (forward-comment -1), point moves one character forward. This leads to an infinite loop in CC Mode code. (Note: for this to manifest, the buffer must, at some stage, have had font lock enabled, setting up some text properties). The immediate cause of this is in Fforward_comment at ~L+168: else if (code == Sendcomment) { -------> found = back_comment (from, from_byte, stop, comnested, comstyle, &out_charpos, &out_bytepos); if (!found) Before the call to back_comment, "print SYNTAX(13)" in gdb returns (correctly) Sendcomment. After back_comment returns, it returns Sclose. (In fact SYNTAX(x), for any x, returns Sclose). So back_comment plays with the current syntax table structure, and fails to restore it properly - it appears that rather than restoring it for ^M, it is setting up the (syntax table property) value of >. 13 lines lower down, we have: if (SYNTAX (c) != code) /* It was a two-char Sendcomment. */ ------------> INC_BOTH (from, from_byte); goto leave; This spurious call to INC_BOTH is what causes the buggy character movement forwards. Looking at back_comment, just after the main loop at L+205, we have the code which restores point and the current syntax table: if (comstart_pos == 0) { from = comment_end; from_byte = comment_end_byte; => UPDATE_SYNTAX_TABLE_FORWARD (comment_end - 1); } It seems to me that that " - 1" is what is causing the syntax table to be restored to the value for ">", and shouldn't be there. Stefan, am I right? -- Alan Mackenzie (Nuremberg, Germany).