Subject: bug#50096: args-out-of-range in redisplay_internal

From: Eli Zaretskii <[email-masked]>
Date: Wed, 18 Aug 2021 20:01:52 +0300

> From: Juri Linkov <[email-masked]>
> Cc: [email-masked]
> Date: Wed, 18 Aug 2021 19:32:01 +0300
> 
> >> I don't understand how this is supposed to work.  The buffer " *Minibuf-0*"
> >> is always empty at the time of calling message3_nolog, whereas the buffer
> >> " *Echo Area 0*" contains the message to display.
> >
> > Yes, some code switches to another buffer at the wrong moment.
> 
> There are no buffer switching involved neither in the successful case
> nor in the failing case.

What is the "successful case" and what is the "failing case"?

I think we've just established that the reason for failure is a longer
line displayed in the mini-window with auto-hscrolling enabled.  So
the problem was probably there for quite some time, it just didn't
happen because two conditions are needed to trigger it:

 . a relatively long line displayed in the mini-window (rare)
 . auto-hscroll enabled in that window (even more rare)

As for switching buffers: how else can you explain that the window's
glyph matrix is correct for another buffer?  And, btw, what is the
value of it->w->contents inside init_to_row_start?  I mean here:

> #11 0x000055c2da79bf2e in init_to_row_start (it=0x7ffdc316c8c0, w=0x55c2dd062400, row=0x55c2e3f9fc50) at xdisp.c:3735

it->w->contents should be a buffer, but what buffer is that?

Also, what is the value of it->w->desired_matrix->buffer->name_ ?
It's a Lisp string, but what's its Lisp value?

> It's 100% reproducible for me, but I'm not sure how easy would be
> to create a test case for "emacs -Q".

I'd appreciate if you could try.

> >> I guess additional ":(literal)" string increases the length
> >> of the displayed message, and longer message triggers the bug.
> >
> > How does it trigger it? via hscrolling or some other way?
> 
> It reduces the length of the displayed message,
> so there is no wrapped line and no hscrolling.

OK, thanks.