Subject: bug#56561: 29.0.50; Infloop in try_window

From: Michael Welsh Duggan <[email-masked]>
Date: Thu, 14 Jul 2022 18:44:43 -0400

Eli Zaretskii <[email-masked]> writes:

>> From: Michael Welsh Duggan <[email-masked]>
>> Date: Thu, 14 Jul 2022 14:57:40 -0400
>> 
>> I've connected to this in gdb.  `try_window' is calling `display_line'
>> in a loop until the iterator hits a certain point.  But `display_line',
>> in this case, isn't modifying the iterator, so the loop never ends.
>> Here follows part of the debugging session demonstrating this.  I'll
>> keep this gdb session alive for a while.
>
> I need to see what's in the buffer and some other variables.  These
> are for the call-stack frame inside display_line:
>
>   (gdb) p current_buffer->text->beg
>   (gdb) p it->current
>   (gdb) p it->w->desired_matrix->nrows
>   (gdb) p MATRIX_ROW_VPOS(row, it->w->desired_matrix)
>   (gdb) thread apply all bt
>   (gdb) xbacktrace
>
> And finally, any idea what you were doing when this happened?

Moving my cursor between frames and either clicking or typing C-p, I
think.  The emacs was on a remote machine at the time, visible via X11
over ssh.  This may have slowed X events enough for some corner
condition to be achieved.

(gdb) p current_thread->m_current_buffer->text->beg
$15 = (unsigned char *) 0x555557bb75a0 "mouse-2: correct word at point"
(gdb) p it->current
$16 = {
  pos = {
    charpos = 31,
    bytepos = 31
  },
  overlay_string_index = -1,
  string_pos = {
    charpos = -1,
    bytepos = -1
  },
  dpvec_index = -1
}
(gdb) p it->w->desired_matrix->nrows
$17 = 35
(gdb) p MATRIX_ROW_VPOS(row, it->w->desired_matrix)
No symbol "MATRIX_ROW_VPOS" in current context.
(gdb) p row - it->w->desired_matrix->rows
$18 = 35

Thread 4 (Thread 0x7fffe7fff640 (LWP 1400080) "gdbus"):
#0  0x00007ffff3cb487f in __GI___poll (fds=0x7ffff6b0f4e0, nfds=140737331255742, timeout=32767) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007fffe0016990 in  ()
#2  0x00007fffe0016990 in  ()
#3  0x0000000000000002 in  ()
#4  0xffffffff00000001 in  ()
#5  0x00007fffe0014ca0 in  ()
#6  0x00007ffff6a2e1ee in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#7  0x00007ffff6a2e543 in g_main_loop_run () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#8  0x00007ffff6cc3cf6 in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#9  0x00007fffe0002de0 in  ()
#10 0x00007ffff6a5859d in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#11 0x00007ffff61a6d80 in start_thread (arg=0x7fffe7fff640) at pthread_create.c:481
#12 0x00007ffff3cc076f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
#13 0x0000000000000000 in  ()

Lisp Backtrace:
"x-show-tip" (0xffffcdb0)
"tooltip-show" (0xffffced8)
"tooltip-help-tips" (0xffffd038)
"tooltip-timeout" (0xffffd278)
"apply" (0xffffd270)
"timer-event-handler" (0xffffd3f8)

Thread 3 (Thread 0x7fffece4a640 (LWP 1400079) "dconf worker"):
#0  0x00007ffff3cb487f in __GI___poll (fds=0x7ffff6b0f4e0, nfds=140737331255742, timeout=32767) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00005555573d6900 in  ()
#2  0x00005555573d6900 in  ()
#3  0x0000000000000001 in  ()
#4  0xffffffff00000001 in  ()
#5  0x00005555573d6810 in  ()
#6  0x00007ffff6a2e1ee in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#7  0x00007ffff6a2e30f in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#8  0x00007fffeceab3bd in  () at /usr/lib/x86_64-linux-gnu/gio/modules/libdconfsettings.so
#9  0x00007ffff6a5859d in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#10 0x00007ffff61a6d80 in start_thread (arg=0x7fffece4a640) at pthread_create.c:481
#11 0x00007ffff3cc076f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
#12 0x0000000000000000 in  ()

Lisp Backtrace:
"x-show-tip" (0xffffcdb0)
"tooltip-show" (0xffffced8)
"tooltip-help-tips" (0xffffd038)
"tooltip-timeout" (0xffffd278)
"apply" (0xffffd270)
"timer-event-handler" (0xffffd3f8)

Thread 2 (Thread 0x7fffee6ca640 (LWP 1399543) "gmain"):
#0  0x00007ffff3cb487f in __GI___poll (fds=0x7ffff6b0f4e0, nfds=140737331255742, timeout=0) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x0000555555ccf0d0 in  ()
#2  0x0000555555ccf0d0 in  ()
#3  0x0000000000000001 in  ()
#4  0xffffffff00000001 in  ()
#5  0x0000555555edd870 in  ()
#6  0x00007ffff6a2e1ee in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#7  0x00007ffff6a2e30f in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#8  0x00007ffff6a2e361 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#9  0x00007ffff6a5859d in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#10 0x00007ffff61a6d80 in start_thread (arg=0x7fffee6ca640) at pthread_create.c:481
#11 0x00007ffff3cc076f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
#12 0x0000000000000000 in  ()

Lisp Backtrace:
"x-show-tip" (0xffffcdb0)
"tooltip-show" (0xffffced8)
"tooltip-help-tips" (0xffffd038)
"tooltip-timeout" (0xffffd278)
"apply" (0xffffd270)
"timer-event-handler" (0xffffd3f8)

Thread 1 (Thread 0x7ffff05e1380 (LWP 1399519) "emacs"):
#0  0x00005555555e461a in display_line (it=it@entry=0x7fffffffb770, cursor_vpos=cursor_vpos@entry=0) at ../../md5i/src/xdisp.c:24169
#1  0x00005555555e7e01 in try_window (window=window@entry=XIL(0x55555b4301f5), pos=..., flags=flags@entry=2) at ../../md5i/src/xdisp.c:20206
#2  0x00005555556ad347 in Fx_show_tip (string=<optimized out>, frame=<optimized out>, parms=XIL(0x55556045d6d3), timeout=<optimized out>, dx=<optimized out>, dy=<optimized out>) at ../../md5i/src/xfns.c:8752
#3  0x0000555555754d86 in funcall_subr (subr=0x555555bd1c20 <Sx_show_tip>, numargs=numargs@entry=6, args=args@entry=0x7fffffffcdb0) at ../../md5i/src/eval.c:3006
#4  0x0000555555752ca4 in funcall_general (fun=<optimized out>, numargs=numargs@entry=6, args=args@entry=0x7fffffffcdb0) at ../../md5i/src/eval.c:2904
#5  0x0000555555753131 in Ffuncall (nargs=7, args=0x7fffffffcda8) at ../../md5i/src/eval.c:2958
#6  0x00007fffeee6ed9d in F746f6f6c7469702d73686f77_tooltip_show_0 () at /home/md5i/src/emacs/build/src/../native-lisp/29.0.50-bb581598/preloaded/tooltip-29462ede-0f14bf43.eln
#7  0x0000555555754d4f in funcall_subr (subr=0x7fffef911310, numargs=numargs@entry=2, args=args@entry=0x7fffffffced8) at ../../md5i/src/eval.c:3002
#8  0x0000555555752ca4 in funcall_general (fun=<optimized out>, numargs=numargs@entry=2, args=args@entry=0x7fffffffced8) at ../../md5i/src/eval.c:2904
#9  0x0000555555753131 in Ffuncall (nargs=3, args=0x7fffffffced0) at ../../md5i/src/eval.c:2958
#10 0x00007fffeee6f968 in F746f6f6c7469702d68656c702d74697073_tooltip_help_tips_0 () at /home/md5i/src/emacs/build/src/../native-lisp/29.0.50-bb581598/preloaded/tooltip-29462ede-0f14bf43.eln
#11 0x0000555555754d16 in funcall_subr (subr=0x7fffef912e38, numargs=numargs@entry=1, args=args@entry=0x7fffffffd038) at ../../md5i/src/eval.c:2996
#12 0x0000555555752ca4 in funcall_general (fun=<optimized out>, numargs=numargs@entry=1, args=args@entry=0x7fffffffd038) at ../../md5i/src/eval.c:2904
#13 0x0000555555753131 in Ffuncall (nargs=2, args=0x7fffffffd030) at ../../md5i/src/eval.c:2958
#14 0x0000555555751f6c in run_hook_with_args (nargs=2, args=0x7fffffffd030, funcall=funcall@entry=0x555555753016 <Ffuncall>) at ../../md5i/src/eval.c:2817
#15 0x00005555557521df in Frun_hook_with_args_until_success (nargs=<optimized out>, args=<optimized out>) at ../../md5i/src/eval.c:2703
#16 0x00007fffeee6e964 in F746f6f6c7469702d74696d656f7574_tooltip_timeout_0 () at /home/md5i/src/emacs/build/src/../native-lisp/29.0.50-bb581598/preloaded/tooltip-29462ede-0f14bf43.eln
#17 0x0000555555754d16 in funcall_subr (subr=0x7fffef911db8, numargs=numargs@entry=1, args=args@entry=0x7fffffffd278) at ../../md5i/src/eval.c:2996
#18 0x0000555555752ca4 in funcall_general (fun=<optimized out>, numargs=numargs@entry=1, args=args@entry=0x7fffffffd278) at ../../md5i/src/eval.c:2904
#19 0x0000555555753131 in Ffuncall (nargs=nargs@entry=2, args=args@entry=0x7fffffffd270) at ../../md5i/src/eval.c:2958
#20 0x0000555555753c70 in Fapply (nargs=2, args=0x7fffffffd270) at ../../md5i/src/eval.c:2586
#21 0x0000555555754de9 in funcall_subr (subr=0x555555bdf060 <Sapply>, numargs=numargs@entry=2, args=args@entry=0x7fffffffd270) at ../../md5i/src/eval.c:3023
#22 0x0000555555752ca4 in funcall_general (fun=<optimized out>, numargs=numargs@entry=2, args=args@entry=0x7fffffffd270) at ../../md5i/src/eval.c:2904
#23 0x0000555555753131 in Ffuncall (nargs=3, args=0x7fffffffd268) at ../../md5i/src/eval.c:2958
#24 0x00007fffef039e90 in F74696d65722d6576656e742d68616e646c6572_timer_event_handler_0 () at /home/md5i/src/emacs/build/src/../native-lisp/29.0.50-bb581598/preloaded/timer-3ee7cfd9-76499eee.eln
#25 0x0000555555754d16 in funcall_subr (subr=0x7ffff0025ad0, numargs=numargs@entry=1, args=args@entry=0x7fffffffd3f8) at ../../md5i/src/eval.c:2996
#26 0x0000555555752ca4 in funcall_general (fun=<optimized out>, numargs=numargs@entry=1, args=args@entry=0x7fffffffd3f8) at ../../md5i/src/eval.c:2904
#27 0x0000555555753131 in Ffuncall (nargs=nargs@entry=2, args=args@entry=0x7fffffffd3f0) at ../../md5i/src/eval.c:2958
#28 0x00005555556c3cf3 in call1 (arg1=XIL(0x55555bd20ee5), fn=XIL(0xf390)) at ../../md5i/src/lisp.h:3239
#29 timer_check_2 (timers=<optimized out>, timers@entry=XIL(0x55555c403a33), idle_timers=<optimized out>, idle_timers@entry=XIL(0x55555c403803)) at ../../md5i/src/keyboard.c:4599
#30 0x00005555556d1ec0 in timer_check () at ../../md5i/src/keyboard.c:4665
#31 0x00005555556d1f10 in readable_events (flags=1) at ../../md5i/src/keyboard.c:3492
#32 0x00005555556d2254 in get_input_pending (flags=flags@entry=1) at ../../md5i/src/keyboard.c:7240
#33 0x00005555556d238f in swallow_events (do_display=do_display@entry=false) at ../../md5i/src/keyboard.c:4406
#34 0x00005555556d4a90 in read_char (commandflag=1, map=map@entry=XIL(0x55555eba43d3), prev_event=XIL(0), used_mouse_menu=used_mouse_menu@entry=0x7fffffffd7eb, end_time=end_time@entry=0x0) at ../../md5i/src/keyboard.c:2585
#35 0x00005555556d67eb in read_key_sequence (keybuf=keybuf@entry=0x7fffffffd8c0, prompt=prompt@entry=XIL(0), dont_downcase_last=dont_downcase_last@entry=false, can_return_switch_frame=can_return_switch_frame@entry=true, fix_current_buffer=fix_current_buffer@entry=true, prevent_redisplay=prevent_redisplay@entry=false) at ../../md5i/src/keyboard.c:9947
#36 0x00005555556d8257 in command_loop_1 () at ../../md5i/src/keyboard.c:1391
#37 0x00005555557518a6 in internal_condition_case (bfun=bfun@entry=0x5555556d805e <command_loop_1>, handlers=handlers@entry=XIL(0x90), hfun=hfun@entry=0x5555556c8fb3 <cmd_error>) at ../../md5i/src/eval.c:1485
#38 0x00005555556c22a1 in command_loop_2 (handlers=handlers@entry=XIL(0x90)) at ../../md5i/src/keyboard.c:1132
#39 0x000055555575181d in internal_catch (tag=tag@entry=XIL(0xf690), func=func@entry=0x5555556c2287 <command_loop_2>, arg=arg@entry=XIL(0x90)) at ../../md5i/src/eval.c:1208
#40 0x00005555556c2264 in command_loop () at ../../md5i/src/keyboard.c:1110
#41 0x00005555556c8b5a in recursive_edit_1 () at ../../md5i/src/keyboard.c:719
#42 0x00005555556c8eef in Frecursive_edit () at ../../md5i/src/keyboard.c:802
#43 0x00005555556c194f in main (argc=2, argv=0x7fffffffdc68) at ../../md5i/src/emacs.c:2517

Lisp Backtrace:
"x-show-tip" (0xffffcdb0)
"tooltip-show" (0xffffced8)
"tooltip-help-tips" (0xffffd038)
"tooltip-timeout" (0xffffd278)
"apply" (0xffffd270)
"timer-event-handler" (0xffffd3f8)

-- 
Michael Welsh Duggan
([email-masked])