Subject: bug#18912: 24.4; mode-line corruption on graphical frames in dual-headed display

From: Eli Zaretskii <[email-masked]>
Date: Mon, 03 Nov 2014 18:20:27 +0200

> Date: Mon, 03 Nov 2014 04:03:39 -0200
> From: Bruno Félix Rezende Ribeiro <[email-masked]>
> CC: [email-masked], [email-masked]
> 
> Eli Zaretskii wrote:
> > Unnecessary redrawing causes unpleasant flickering that people
> > rightfully complain about.
> 
> It wouldn't be unnecessary because only people having a similar problem
> would deliberately enable the mode-line redrawing.  I can assure you a
> constantly corrupted mode-line is much more annoying than one fast flash
> that will only occur sporadically, in just one line, by direct command
> of the user.  In particular, on scroll operations all lines in the
> window are expected to change, so it's not that bad if just one more
> line, contiguous to the region, flashes.  Actually, the chances are that
> the flash won't be noticeable at all.

I'd like to solve this problem, not paper over it.  I hope you agree
that solving it is better than working around it.

> > Are you willing to debug this problem on your machine using GDB?  If
> > so, I might come up with some instructions.
> 
> Sure, why not?

Thanks, please find the instructions below.

> However, if we can't find the bug's root, I'll ask you to consider
> implementing the suggested workaround.  Deal? ;-)

I find it hard to believe that we won't find the root cause, so I
think we don't need to consider that possibility.

Here are the first instructions to get information that will help us
start digging into this.  (These are in addition to what Martin
already requested.)

First, please build Emacs without optimizations and with extra
checking code enabled:

  CFLAGS='-O0 -g3' ./configure --prefix=/home/felix/opt/emacs-24.4 --with-x-toolkit=athena --enable-checking='yes,glyphs'

(I only care about CFLAGS and the --enable-checking= option; the rest
I just copied from your original report, but feel free to change them
if you want.  The --enable-checking= option is required to compile the
dump-glyph-matrix command I ask you to use below.)

After 'configure' finishes, invoke "make".  You don't have to invoke
"make install", as Emacs can be run from the src/ directory where it
was built.

Now start Emacs you've just build with "emacs -Q", type the "C-x d"
command that you say is sufficient to reproduce the problem, and then
type this:

  M-x dump-glyph-matrix RET

This outputs to the standard error stream the description of the
internal data structure, called "glyph matrix", which Emacs maintains
for each window on a GUI frame.  Please post that output (you may wish
to redirect stderr to a file when you invoke Emacs, to make that
easier).

Please do this once for the "good" configuration, and another time for
the "bad" configuration, but please make sure you invoke Emacs the
same in both cases and type the same "C-x d" command in each case.

Next, in the "bad" configuration and with the listing of /dev and
corrupted mode line displayed, type this:

  M-: (setq frame-resize-pixelwise t) RET

Now carefully decrease the frame's height by dragging its upper or
lower edge with the mouse.  Please drag it slowly and carefully, so
that the frame is resized one pixel at a time.  After each resize,
please see if the mode line is no longer corrupted.  Perhaps kill the
buffer and type "C-x d" again to make sure the corruption disappeared
for good.  The first time the mode line stops being corrupted, type

  M-x dump-glyph-matrix RET

again, and include this (3rd) output in your message.  Also, please
tell how many pixels did you subtract from the original frame height
before the corruption disappeared (assuming it ever does).

Where are the instructions to use the debugger, you ask?  Well, not
yet, but maybe after we see what the above tells us.

Thanks.