Subject: Re: bug#56561: 29.0.50; Infloop in try_window

From: Po Lu <[email-masked]>
Date: Fri, 15 Jul 2022 21:54:24 +0800

Eli Zaretskii <[email-masked]> writes:

>> Cc: [email-masked]
>> Date: Fri, 15 Jul 2022 09:14:10 +0300
>> From: Eli Zaretskii <[email-masked]>
>> 
>> Hmm... so the short tooltip text somehow causes us to exceed the
>> number of glyph rows of the matrix?  Please tell what the commands
>> below show:
>> 
>>  (gdb) pgrowx it->w->desired_matrix->rows
>>  (gdb) pgrowx it->w->desired_matrix->rows+1
>>  (gdb) pgrowx it->w->desired_matrix->rows+2
>>  (gdb) pgrowx it->w->desired_matrix->rows+3
>>  ...
>>  (gdb) pgrowx it->w->desired_matrix->rows+34
>> 
>> That is, I want to see the entire contents of the glyph rows.
>> 
>> Also
>> 
>>  (gdb) p it->last_visible_x
>>  (gdb) p it->last_visible_y
>
> Actually, I think I see the reason.  I installed a fix, but I cannot
> find a way of triggering the problem, so I cannot be 110% sure this is
> fixed.  I guess time will tell.

BTW, I have a question about the fix: redisplay cannot run when a
tooltip is displayed as popup menu help-text, so adjust_glyph_matrix and
the subsequent try_window call that is required to generate the display
contents will not be called in time, leading to a blank tooltip.

The call could previously never fail, since the tooltip code specifies
TRY_WINDOW_IGNORE_FONTS_CHANGE.

Would it be appropriate to call adjust_frame_glyphs and try_window again
if this call to try_window in Fx_show_tip fails?

  specpdl_ref count_1 = SPECPDL_INDEX ();
  old_buffer = current_buffer;
  set_buffer_internal_1 (XBUFFER (w->contents));
  bset_truncate_lines (current_buffer, Qnil);
  specbind (Qinhibit_read_only, Qt);
  specbind (Qinhibit_modification_hooks, Qt);
  specbind (Qinhibit_point_motion_hooks, Qt);
  Ferase_buffer ();
  Finsert (1, &string);
  clear_glyph_matrix (w->desired_matrix);
  clear_glyph_matrix (w->current_matrix);
  SET_TEXT_POS (pos, BEGV, BEGV_BYTE);
->try_window (window, pos, TRY_WINDOW_IGNORE_FONTS_CHANGE);
  /* Calculate size of tooltip window.  */
  size = Fwindow_text_pixel_size (window, Qnil, Qnil, Qnil,
				  make_fixnum (w->pixel_height), Qnil,
				  Qnil);

Thanks.