Subject: Re: bug#27668: 26.0.50; Crash with display-line-numbers t

From: Robert Pluim <[email-masked]>
Date: Fri, 14 Jul 2017 16:47:56 +0200

Eli Zaretskii <[email-masked]> writes:

>> From: Robert Pluim <[email-masked]>
>> Would you like me to try an unoptimised build? CFLAGS=-O0 -ggdb or
>> similar?
>
> It cannot hurt, so please do.  Maybe this will give some valuable
> hints.  (Please use "-gdwarf-4 -g3" instead of -ggdb, it should
> provide a better debug info.)  Btw, I already did an optimized build,
> but was unable to reproduce the problem there as well.
>

I'll try that next, I think you're on the right track.

> When the assertion in maybe_produce_line_number is hit, what are the
> values of it->vpos and it->glyph_row->y?  Are they always the same
> values?  If they are, maybe we could put a watchpoint on the
> corresponding glyph row and see who changes it.

They're both always 0.

21012	  eassert (it->glyph_row == NULL || it->glyph_row->used[TEXT_AREA] == 0);
(gdb) p it->vpos
$5 = 0
(gdb) p it->glyph_row->y
$6 = 0

> The problem seems to be that display_line starts producing glyphs in a
> glyph row which wasn't cleared, i.e. its used[1] counter is non-zero.
> The call to prepare_desired_row at the beginning of display_line is
> supposed to do that, but only if the row->enabled_p flag is reset.
> This flag should be reset for all the glyph rows of the window's
> desired_matrix, because redisplay calls clear_glyph_matrix for
> w->desired_matrix, directly and indirectly, in many places.  Somehow
> in your case either those calls to clear_glyph_matrix are bypassed or
> some code sets the enabled_p flag at some point and doesn't reset it
> before the call to try_window on line 16991 of xdisp.c.  I'm trying to
> establish where does this happen and why.
>
> Just to make sure I'm on the right track: if you make the change
> below, does the problem go away?
>

Yes. Without the patch I ran my eww recipe three times, it crashed
three times. With the patch, I ran it three times in 3 separate
instances of emacs, no crash so far (and I tried a bunch of the magit
related operations as well for good measure, and I'm using the
resulting emacs to send this).

Regards

Robert