unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46400: Sporadically breaking newline-indentation in c-mode
@ 2021-02-09 12:45 Konstantin Kharlamov
  2021-02-09 22:13 ` bug#46400: [BISECTED] " Konstantin Kharlamov
  0 siblings, 1 reply; 9+ messages in thread
From: Konstantin Kharlamov @ 2021-02-09 12:45 UTC (permalink / raw)
  To: 46400

This is a regression, but I'm not sure when it was introduced. Upon pressing
RET, sometimes indentation gets inserted and you get the caret is on top of
indentation; other times no indentation is inserted and the caret ends up at the
beginning of a new line.

There is not pattern, and both cases may happen many times in the row upon
pressing RET.

It is worth noting that this only happens in certain syntax parts of c-code.

To reproduce the problem you basically put the caret at certain location in
text, and spam RET and undo till some "RET" results in no indentation inserted
(indentation seems expected by default, so it's not expected bahavior).

# Steps to reproduce

1. Create /tmp/.emacs file with the following content:

    (defun test ()
      (let ((i 0)
            (searching t))
        (while (and (< i 10) searching)
          (setq i (+ i 1))
          (call-interactively 'newline)
          (if (eq (line-beginning-position) (point))
              (setq searching nil)
            (call-interactively 'undo))
          )
        (format "exiting with i = %d" i)))

2. Create `test.c` file with the following content:

    void foo() {
        if (-1 == dest)
        {
            bar("Couldn't open %s", to);
            goto exit;
        }
    }

3. Run emacs as `env HOME=/tmp/ emacs test.c`
4. Put caret at the end of `bar("Couldn't open %s", to);` text, right after the
semicolon
5. Evaluate (test)

NOTE: to make this work I had to evaluate the 5-th step twice. The reason is
that `undo` in here behaves oddly: often it just refuses to undo with "No
further undo unformation", thus making function evaluation stop. I'm not sure
what to do about that problem; however repeating the call second time seems to
always reproduce the problem for me.

## Expected

Whenever `(test)` completes, the text is unchanged.

## Actual

At some point you end up with caret being at the beginning of a new line (i.e.
no indentation on that line)

# Version

Latest Emacs build:

    GNU Emacs 28.0.50 (build 12, x86_64-pc-linux-gnu, GTK+ Version 3.24.24,
cairo version 1.17.4) of 2021-02-09

Also tested on a build from a few weeks ago, commit 9503f8d96c







^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#46400: [BISECTED] Sporadically breaking newline-indentation in c-mode
  2021-02-09 12:45 bug#46400: Sporadically breaking newline-indentation in c-mode Konstantin Kharlamov
@ 2021-02-09 22:13 ` Konstantin Kharlamov
  2021-02-12 14:08   ` Konstantin Kharlamov
  0 siblings, 1 reply; 9+ messages in thread
From: Konstantin Kharlamov @ 2021-02-09 22:13 UTC (permalink / raw)
  To: 46400; +Cc: acm

I just bisected it to a commit 

    3096437593 CC Mode: introduce a new cache for brace structures.  This fixes bug #45248

before this commit I couldn't reproduce it, and on this I reproduce it immediately.

CCing the commit author.






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#46400: [BISECTED] Sporadically breaking newline-indentation in c-mode
  2021-02-09 22:13 ` bug#46400: [BISECTED] " Konstantin Kharlamov
@ 2021-02-12 14:08   ` Konstantin Kharlamov
  2021-02-12 14:56     ` Alan Mackenzie
  0 siblings, 1 reply; 9+ messages in thread
From: Konstantin Kharlamov @ 2021-02-12 14:08 UTC (permalink / raw)
  To: 46400; +Cc: acm

On Wed, 2021-02-10 at 01:13 +0300, Konstantin Kharlamov wrote:
> I just bisected it to a commit 
> 
>     3096437593 CC Mode: introduce a new cache for brace structures.  This
> fixes bug #45248
> 
> before this commit I couldn't reproduce it, and on this I reproduce it
> immediately.
> 
> CCing the commit author.

So, what's the plan here? Should I send a revert?

CC: Alan Mackenzie (I know I already CCed, but I figured they might not know they were mentioned if they has mail filters for example, since I didn't write the name).






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#46400: [BISECTED] Sporadically breaking newline-indentation in c-mode
  2021-02-12 14:08   ` Konstantin Kharlamov
@ 2021-02-12 14:56     ` Alan Mackenzie
  2021-02-12 15:46       ` Konstantin Kharlamov
  2021-02-17 21:59       ` Konstantin Kharlamov
  0 siblings, 2 replies; 9+ messages in thread
From: Alan Mackenzie @ 2021-02-12 14:56 UTC (permalink / raw)
  To: Konstantin Kharlamov; +Cc: acm, 46400

Hello, Konstantin.

First of all, thanks for taking the trouble to report this bug, and
thanks even more for taking the diagnosis so far.

On Fri, Feb 12, 2021 at 17:08:19 +0300, Konstantin Kharlamov wrote:
> On Wed, 2021-02-10 at 01:13 +0300, Konstantin Kharlamov wrote:
> > I just bisected it to a commit 

> >     3096437593 CC Mode: introduce a new cache for brace structures.  This
> > fixes bug #45248

> > before this commit I couldn't reproduce it, and on this I reproduce it
> > immediately.

> > CCing the commit author.

> So, what's the plan here? Should I send a revert?

No, please don't do that - that was an essential fix for a performance
bug.

> CC: Alan Mackenzie (I know I already CCed, but I figured they might
> not know they were mentioned if they has mail filters for example,
> since I didn't write the name).

Sorry, I should have got back to you sooner, but I wanted to have
something to show.

I don't think the bug was introduced by the commit you cite, more likely
that commit triggered the bug which was lying in wait elsewhere.

I've been working on this bug for several hours, so far, and have found
that the "c-state-cache" (which records the positions of certain braces,
brackets and parentheses) becomes corrupt while running your `test'
function.  I'm trying to track down where and how this corruption
happens.

Also relevant is that the bug seems to be being triggered by the
apostrophe in

    bar("Couldn't open %s", to);
               ^

..  At least, if I take that apostrophe away, I don't see the bug
symptoms any more.

So, please bear with me some while longer.  I am working on the bug.

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#46400: [BISECTED] Sporadically breaking newline-indentation in c-mode
  2021-02-12 14:56     ` Alan Mackenzie
@ 2021-02-12 15:46       ` Konstantin Kharlamov
  2021-02-17 21:59       ` Konstantin Kharlamov
  1 sibling, 0 replies; 9+ messages in thread
From: Konstantin Kharlamov @ 2021-02-12 15:46 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 46400

On Fri, 2021-02-12 at 14:56 +0000, Alan Mackenzie wrote:
> Hello, Konstantin.
> 
> First of all, thanks for taking the trouble to report this bug, and
> thanks even more for taking the diagnosis so far.
> 
> On Fri, Feb 12, 2021 at 17:08:19 +0300, Konstantin Kharlamov wrote:
> > On Wed, 2021-02-10 at 01:13 +0300, Konstantin Kharlamov wrote:
> > > I just bisected it to a commit 
> 
> > >     3096437593 CC Mode: introduce a new cache for brace structures.  This
> > > fixes bug #45248
> 
> > > before this commit I couldn't reproduce it, and on this I reproduce it
> > > immediately.
> 
> > > CCing the commit author.
> 
> > So, what's the plan here? Should I send a revert?
> 
> No, please don't do that - that was an essential fix for a performance
> bug.
> 
> > CC: Alan Mackenzie (I know I already CCed, but I figured they might
> > not know they were mentioned if they has mail filters for example,
> > since I didn't write the name).
> 
> Sorry, I should have got back to you sooner, but I wanted to have
> something to show.
> 
> I don't think the bug was introduced by the commit you cite, more likely
> that commit triggered the bug which was lying in wait elsewhere.
> 
> I've been working on this bug for several hours, so far, and have found
> that the "c-state-cache" (which records the positions of certain braces,
> brackets and parentheses) becomes corrupt while running your `test'
> function.  I'm trying to track down where and how this corruption
> happens.
> 
> Also relevant is that the bug seems to be being triggered by the
> apostrophe in
> 
>     bar("Couldn't open %s", to);
>                ^
> 
> ..  At least, if I take that apostrophe away, I don't see the bug
> symptoms any more.
> 
> So, please bear with me some while longer.  I am working on the bug.
> 

D: Oh, this is cool! Sure, thank you very much for looking into it! I'm definitely not in hurry, I was just kinda being afraid that the report could've gotten through the cracks. I'm happy to hear that wasn't the case ☺






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#46400: [BISECTED] Sporadically breaking newline-indentation in c-mode
  2021-02-12 14:56     ` Alan Mackenzie
  2021-02-12 15:46       ` Konstantin Kharlamov
@ 2021-02-17 21:59       ` Konstantin Kharlamov
  2021-02-18 11:21         ` Alan Mackenzie
  1 sibling, 1 reply; 9+ messages in thread
From: Konstantin Kharlamov @ 2021-02-17 21:59 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 46400

Hey! Sorry: I'm replying to the wrong email because it seems I stopped receiving
notifications for the report since the last time I sent an email here. I didn't even
know there was a discussion ongoing till I occasionally looked through the web
interface ☺ The web-interface doesn't allow to reply a specific comment, so I had to
reply to an arbitrary email, last one I got in my mailbox. Sorry. (on a side-note,
Idk what happened to notifications. I looked through spam and other folders, tried
using built-in search on my email-provider in case some filter put them into a random
folder, but emails are nowhere to be seen. Looks like I just wasn't getting any
notifications).

Alan Mackenzie wrote:

> A pleasure!  I intend to commit the patch below in a few days time, if I don't hear
> back from anybody that it's giving trouble.  This patch fixes the bug when applied
> to that commit from December (9022df70270243f211c54ccd66800320148b8434).  It should
> apply cleanly to master.

Oh, this is amazing! I'll give the patch a try as well. I assume though there will be
nothing to report (well, other than "Thank you for fixing the bug" 😉), but if I
happen to find some other problem, I'll make sure to drop an email either here or to
a new report :)






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#46400: [BISECTED] Sporadically breaking newline-indentation in c-mode
  2021-02-17 21:59       ` Konstantin Kharlamov
@ 2021-02-18 11:21         ` Alan Mackenzie
  2021-02-23 11:26           ` Alan Mackenzie
       [not found]           ` <YDTmW5Fi8xBc0Wja@ACM>
  0 siblings, 2 replies; 9+ messages in thread
From: Alan Mackenzie @ 2021-02-18 11:21 UTC (permalink / raw)
  To: Konstantin Kharlamov; +Cc: 46400

Hello, Konstantin.

On Thu, Feb 18, 2021 at 00:59:08 +0300, Konstantin Kharlamov wrote:
> Hey! Sorry: I'm replying to the wrong email because it seems I stopped
> receiving notifications for the report since the last time I sent an
> email here. I didn't even know there was a discussion ongoing till I
> occasionally looked through the web interface ☺ The web-interface
> doesn't allow to reply a specific comment, so I had to reply to an
> arbitrary email, last one I got in my mailbox. Sorry. (on a side-note,
> Idk what happened to notifications. I looked through spam and other
> folders, tried using built-in search on my email-provider in case some
> filter put them into a random folder, but emails are nowhere to be
> seen. Looks like I just wasn't getting any notifications).

I kept getting rejections from you mail server (something to do with my
ISP's server not sending a STARTTLS operator), so in the end I stopped
adding your address to the To: or Cc: headers.

It might well be I messed something up when I merged this bug with the
other one.  I've not done merging of bugs very often.

Sorry you didn't get the posts from debbugs.gnu.org.

> Alan Mackenzie wrote:

> > A pleasure!  I intend to commit the patch below in a few days time,
> > if I don't hear back from anybody that it's giving trouble.  This
> > patch fixes the bug when applied to that commit from December
> > (9022df70270243f211c54ccd66800320148b8434).  It should apply cleanly
> > to master.

> Oh, this is amazing! I'll give the patch a try as well. I assume though
> there will be nothing to report (well, other than "Thank you for fixing
> the bug" 😉), but if I happen to find some other problem, I'll make
> sure to drop an email either here or to a new report :)

Thank you, indeed!  I haven't committed the patch, yet, and I'll leave
off a few days yet.  It's surprising just how often asking people to
check patches for their bugs gets a reply that things aren't properly
fixed.

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#46400: [BISECTED] Sporadically breaking newline-indentation in c-mode
  2021-02-18 11:21         ` Alan Mackenzie
@ 2021-02-23 11:26           ` Alan Mackenzie
       [not found]           ` <YDTmW5Fi8xBc0Wja@ACM>
  1 sibling, 0 replies; 9+ messages in thread
From: Alan Mackenzie @ 2021-02-23 11:26 UTC (permalink / raw)
  To: Konstantin Kharlamov; +Cc: 46400

Hello again, Konstantin.

On Thu, Feb 18, 2021 at 11:21:50 +0000, Alan Mackenzie wrote:
> On Thu, Feb 18, 2021 at 00:59:08 +0300, Konstantin Kharlamov wrote:
> > Hey! Sorry: I'm replying to the wrong email because it seems I stopped
> > receiving notifications for the report since the last time I sent an
> > email here. I didn't even know there was a discussion ongoing till I
> > occasionally looked through the web interface ☺ The web-interface
> > doesn't allow to reply a specific comment, so I had to reply to an
> > arbitrary email, last one I got in my mailbox. Sorry. (on a side-note,
> > Idk what happened to notifications. I looked through spam and other
> > folders, tried using built-in search on my email-provider in case some
> > filter put them into a random folder, but emails are nowhere to be
> > seen. Looks like I just wasn't getting any notifications).

> I kept getting rejections from you mail server (something to do with my
> ISP's server not sending a STARTTLS operator), so in the end I stopped
> adding your address to the To: or Cc: headers.

Apologies: I got your email address confused with another one beginning
with 'k'.  Your address works just fine, and I never deliberately
omitted it from a Cc:.

> It might well be I messed something up when I merged this bug with the
> other one.  I've not done merging of bugs very often.

> Sorry you didn't get the posts from debbugs.gnu.org.

> > Alan Mackenzie wrote:

> > > A pleasure!  I intend to commit the patch below in a few days time,
> > > if I don't hear back from anybody that it's giving trouble.  This
> > > patch fixes the bug when applied to that commit from December
> > > (9022df70270243f211c54ccd66800320148b8434).  It should apply cleanly
> > > to master.

> > Oh, this is amazing! I'll give the patch a try as well. I assume though
> > there will be nothing to report (well, other than "Thank you for fixing
> > the bug" 😉), but if I happen to find some other problem, I'll make
> > sure to drop an email either here or to a new report :)

> Thank you, indeed!  I haven't committed the patch, yet, and I'll leave
> off a few days yet.  It's surprising just how often asking people to
> check patches for their bugs gets a reply that things aren't properly
> fixed.

I have now committed the patch to all relevant places, and I'm going to
close bug #45375 (which has been merged with bug #46400) next.

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#46400: [BISECTED] Sporadically breaking newline-indentation in c-mode
       [not found]           ` <YDTmW5Fi8xBc0Wja@ACM>
@ 2021-02-23 11:32             ` Konstantin Kharlamov
  0 siblings, 0 replies; 9+ messages in thread
From: Konstantin Kharlamov @ 2021-02-23 11:32 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 46400

On Tue, 2021-02-23 at 11:26 +0000, Alan Mackenzie wrote:
> Hello again, Konstantin.

Hello!

> Apologies: I got your email address confused with another one beginning
> with 'k'.  Your address works just fine, and I never deliberately
> omitted it from a Cc:.
> 
> > It might well be I messed something up when I merged this bug with the
> > other one.  I've not done merging of bugs very often.
> 
> > Sorry you didn't get the posts from debbugs.gnu.org.

No worries!

> > > Alan Mackenzie wrote:
> 
> > > > A pleasure!  I intend to commit the patch below in a few days time,
> > > > if I don't hear back from anybody that it's giving trouble.  This
> > > > patch fixes the bug when applied to that commit from December
> > > > (9022df70270243f211c54ccd66800320148b8434).  It should apply cleanly
> > > > to master.
> 
> > > Oh, this is amazing! I'll give the patch a try as well. I assume though
> > > there will be nothing to report (well, other than "Thank you for fixing
> > > the bug" 😉), but if I happen to find some other problem, I'll make
> > > sure to drop an email either here or to a new report :)
> 
> > Thank you, indeed!  I haven't committed the patch, yet, and I'll leave
> > off a few days yet.  It's surprising just how often asking people to
> > check patches for their bugs gets a reply that things aren't properly
> > fixed.
> 
> I have now committed the patch to all relevant places, and I'm going to
> close bug #45375 (which has been merged with bug #46400) next.


Thank you! FTR, I have used your patch since my previous email, and haven't
noticed any problems. In fact, I even found one thing fixed (but I don't know if
it's relevant to the patch or was it some other change on master), which is that
if I remove a " symbol around a string, code gets re-highlighted immediately (I
seem to remember it was rehighlighted with a delay previously).

So, all in all, my experience is great so far!






^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-02-23 11:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-09 12:45 bug#46400: Sporadically breaking newline-indentation in c-mode Konstantin Kharlamov
2021-02-09 22:13 ` bug#46400: [BISECTED] " Konstantin Kharlamov
2021-02-12 14:08   ` Konstantin Kharlamov
2021-02-12 14:56     ` Alan Mackenzie
2021-02-12 15:46       ` Konstantin Kharlamov
2021-02-17 21:59       ` Konstantin Kharlamov
2021-02-18 11:21         ` Alan Mackenzie
2021-02-23 11:26           ` Alan Mackenzie
     [not found]           ` <YDTmW5Fi8xBc0Wja@ACM>
2021-02-23 11:32             ` Konstantin Kharlamov

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).