From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>, Eli Zaretskii <eliz@gnu.org>
Cc: Marty Rosenberg <marty.rosenberg@gmail.com>, 18022@debbugs.gnu.org
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 [thread overview]
Message-ID: <20140719203310.GA12706@acm.acm> (raw)
In-Reply-To: <20140716214144.GA4052@acm.acm>
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 <bool b>^MSimulatorBase<b>::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).
next prev parent reply other threads:[~2014-07-19 20:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-15 3:13 bug#18022: 24.3; Emacs hard locks when attempting to do a replacement with ^M in it Marty Rosenberg
2014-07-15 14:19 ` Eli Zaretskii
[not found] ` <CAGv7PEAuRvfarf=Lumi-x-S2UCiK-29=DfET1On6jpyBX1y9=w@mail.gmail.com>
2014-07-15 16:46 ` Eli Zaretskii
2014-07-16 21:41 ` Alan Mackenzie
2014-07-19 20:33 ` Alan Mackenzie [this message]
2014-07-23 18:41 ` Alan Mackenzie
[not found] ` <20140723184146.GA2969@acm.acm>
2014-07-25 22:23 ` Stefan Monnier
2014-10-04 18:38 ` Alan Mackenzie
[not found] ` <20141004183822.GA3144@acm.acm>
2014-10-04 22:31 ` Stefan Monnier
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=20140719203310.GA12706@acm.acm \
--to=acm@muc.de \
--cc=18022@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=marty.rosenberg@gmail.com \
--cc=monnier@iro.umontreal.ca \
/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).