Subject: bug#24109: 24.5; Long lines in message mode make Emacs irresponsive

From: Eli Zaretskii <[email-masked]>
Date: Wed, 31 Aug 2016 17:37:55 +0300

> From: Yuri D'Elia <[email-masked]>
> Cc: [email-masked], [email-masked], [email-masked], [email-masked]
> Date: Wed, 31 Aug 2016 11:15:25 +0200
> 
> > What should NOT happen is that the values of it.current.pos stay
> > constant, or cycle endlessly between the same values.  If you can look
> > at that, please do.
> 
> I set a breakpoint and dumped the value of it->current.pos.
> It seems to cycle every 54 iterations. Attached.

Thanks.  Next, we need to establish whether try_window loops in its
loop indefinitely, or its caller calls it in an infinite loop.

The main loop in try_window is this:

  /* Display all lines of W.  */
  while (it.current_y < it.last_visible_y)
    {
      if (display_line (&it))
	last_text_row = it.glyph_row - 1;
      if (f->fonts_changed && !(flags & TRY_WINDOW_IGNORE_FONTS_CHANGE))
	return 0;
    }

Please see if the loop terminates, by setting a breakpoint on the
'return 0' statement and on the line after the loop.

If it terminates, it means try_window does its job correctly, and we
will need to look in the caller, redisplay_window, for the reasons of
this infloop.

> >> Is there some way to conveniently dump the entire buffer state to a file
> >> so we can debug this by reloading the content without having the mail
> >> client in the way?
> >
> > Not that I know of.
> 
> Then, debugging this will be super-annoying :/

Not necessarily, it could be a very simple problem.

Besides, even if there was such a feature, the full state that affects
the display is huge: it should include, in addition to the text
itself, all the text properties, all the face definitions, all the
overlays -- and some of these are dynamically calculated as part of
redisplay.  Even if you could give me that, I'm not sure I could have
spotted the root cause there.