Subject: bug#32351: assq_no_quit: circular loop (default, line-number, line-number-current-line)

From: Keith David Bershatsky <[email-masked]>
Date: Sat, 04 Aug 2018 20:26:33 -0700

Yes, refusing to display the line numbers seems like a good choice to avoid a never-ending infinite loop.

At the outset of maybe_produce_line_number, I added the following code:

  int text_area_width = window_box_width (it->w, TEXT_AREA);
  if (!NILP (Vdisplay_line_numbers)
      && text_area_width < it->lnum_pixel_width)
    return;

It does not necessarily have to be that code exactly, but something along those lines would suffice.

And, the never-ending loop is now gone when using the above modification.  Due to my inexperience with gdb, I erroneously assumed that assq_no_quit or the function calling it was to blame.  However, pressing C-z to break with gdb simply ended up on assq_no_quit by the laws of probability because the LIST takes more time to process than everything else in the redisplay of the target window loop.  By setting up a break in maybe_produce_line_numbers and other functions, I was able to see that the loop is caused by trying/retrying to display the window containing line numbers.

With the above code, redisplay finishes successfully and I can see that just one (1) column of text is visible in the tall/thin sliver of a window.  And, the above code of course disables line numbers in this situation.

If it is not too much trouble, would it be possible for you to please teach me how to print a human-readable int with gdb such as text_area_width.  I ended up with:

(gdb) print text_area_width 
$1 = 1606380704

To see a human-readable value, I turned it into a Lisp Object and used pp OBJECT.  It would be nice to print int values from gdb and see human readable values without modifying the code to turn the int it into a Lisp Object prior thereto.

Thanks,

Keith

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

> Date: [08-03-2018 10:54:37] <03 Aug 2018 20:54:37 +0300>
> From: Eli Zaretskii <[email-masked]>
> To: Keith David Bershatsky <[email-masked]>
> CC: [email-masked]
> Subject: Re: bug#32351: assq_no_quit: circular loop (default, line-number, line-number-current-line)
> 
> > Date:  Fri, 03 Aug 2018 08:17:30 -0700
> > From:  Keith David Bershatsky <[email-masked]>
> > Cc:  [email-masked]
> >
> > 1.  Original single window in a GUI frame with native line numbers and truncate-lines non-nil.
> >
> > 2.  Try to create/display a new window to the right that takes up approximately 95 percent of the overall frame; e.g., my custom 12 month rotating calendar.  [A workaround would be "well, if it hurts, then don't do that".  However, it would be nice to come up with a programmatic solution to avoid a never-ending loop.]
> >
> > 3.  Emacs tries to display line numbers on the little sliver of a tall/razor-thin window.  However, redisplay never finishes so the new window is not yet displayed and all that is visible to the naked eye is the full-size original window.
> >
> > 4.  assq_no_quit goes into a forever never-ending loop.
> 
> Are you saying that this happens when the window is too narrow to show
> the line numbers?  If so, what solution would you like to have? refuse
> to display the line numbers?