Subject: bug#27668: 26.0.50; Crash with display-line-numbers t

From: Robert Pluim <[email-masked]>
Date: Fri, 14 Jul 2017 13:45:04 +0200

Eli Zaretskii <[email-masked]> writes:

>> From: Robert Pluim <[email-masked]>
>>
> In this frame #5, in redisplay_window, which of the conditions in the
> following 'if' clause are true?
>
>       /* Try to redisplay starting at same place as before.
>          If point has not moved off frame, accept the results.  */
>       if (!current_matrix_up_to_date_p
> 	  /* Don't use try_window_reusing_current_matrix in this case
> 	     because a window scroll function can have changed the
> 	     buffer.  */
> 	  || !NILP (Vwindow_scroll_functions)
> 	  || MINI_WINDOW_P (w)
> 	  || !(used_current_matrix_p
> 	       = try_window_reusing_current_matrix (w)))
> 	{
> 	  IF_DEBUG (debug_method_add (w, "1"));
> 	  if (try_window (window, startp, TRY_WINDOW_CHECK_MARGINS) < 0)
>
> It cannot be MINI_WINDOW_P, so it's either current_matrix_up_to_date_p
> is false, or your window-scroll-functions is non-nil, or we called
> try_window_reusing_current_matrix.  In the latter case, I'd expect my
> recent change to fix the problem, so I guess that function wasn't
> called, and some other condition caused us to call try_window.  Or
> maybe I'm missing something here.
>

(gdb) p used_current_matrix_p
$1 = false
(gdb) p Vwindow_scroll_functions
$2 = XIL(0)
(gdb) p w
$3 = <optimized out>
(gdb) p current_matrix_up_to_date_p
$4 = false

Would you like me to try an unoptimised build? CFLAGS=-O0 -ggdb or
similar?

>> I was looking at a commit in Magit, and had just hit enter in a diff
>> hunk to view the source file containing the change, so it's happening
>> when we switch from non-line-number to line-number mode.
>
> How do you "switch from non-line-number to line-number mode"?  I tried
> several ways I could think about, but couldn't reproduce the issue.  I
> wonder what's different in your case that you hit this problem so
> frequently.
>

Basically, I have a buffer where display-line-numbers is nil, then I
either switch to a buffer where it's t or visit a file where the
mode-hook sets it to t. In this case I was looking at a diff hunk,
where Magit does all sorts of highlighting and font-locking, and it
visits the underlying file for you when you hit RET

> Did the previous times also happened when switching from a Magit
> buffer to a buffer under display-line-numbers?

No, previous times were when calling C-x C-f from a buffer with
display-line-numbers t

Regards

Robert