Subject: Re: bug#77065: 31.0.50; Infinite loop in move_it_to

From: Eli Zaretskii <[email-masked]>
Date: Fri, 21 Mar 2025 18:24:50 +0200

> Date: Thu, 20 Mar 2025 09:39:03 -0700
> Cc: [email-masked]
> From: Yifan Zhu <[email-masked]>
> 
> On 3/20/25 3:39 AM, Eli Zaretskii wrote:
> > But the
> > patch below should fix this particular problem, I think; please try
> > it and tell if it avoids the infloop.
> >
> > diff --git a/src/xdisp.c b/src/xdisp.c
> > index c396b213..90ec187 100644
> > --- a/src/xdisp.c
> > +++ b/src/xdisp.c
> > @@ -10295,10 +10295,10 @@ #define IT_RESET_X_ASCENT_DESCENT(IT)			\
> >   		{
> >   		  bool moved_forward = false;
> >   
> > -		  if (/* IT->hpos == 0 means the very first glyph
> > -			 doesn't fit on the line, e.g. a wide
> > -			 image.  */
> > -		      it->hpos == 0
> > +		  if (/* IT->hpos == 0 (modulo line-number width) means
> > +			 the very first glyph doesn't fit on the line,
> > +			 e.g., a wide image.  */
> > +		      it->hpos == 0 + (it->lnum_width ? it->lnum_width + 2 : 0)
> >   		      || (new_x == it->last_visible_x
> >   			  && FRAME_WINDOW_P (it->f)))
> >   		    {
> 
> Thanks! I applied the patch and can no longer reproduce the freezing 
> issue I encountered. There seems to be some display issues in 
> visual-line-mode, but those don't seem to be regressions and I will 
> report those separately.

Thanks, I've now installed the change on the master branch, and I will
close this bug.

> Searching through the file, there are multiple other occurrences of 
> "IT->hpos == 0". Do those need to be changed as well?

Only one, which I did.  The others are either really for hpos == 0 or
have some other heuristics that covers this case.