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

From: Yifan Zhu <[email-masked]>
Date: Thu, 20 Mar 2025 09:39:03 -0700

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.

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