Subject: bug#32537: 26.1.50; Tramp: Cursor jumps when typing during asynchronous find-file

From: Gemini Lasswell <[email-masked]>
Date: Fri, 31 Aug 2018 09:52:45 -0700

Eli Zaretskii <[email-masked]> writes:

> But I still am not sure whether this is our villain.
> Does buffer position 146 sound correct wrt what you see in *scratch*,
> i.e. is it the position where point jumps?  Also, please add to the
> breakpoint commands the command to display the current buffer:
>
>    pp current_buffer->name_
>
> Thanks.

The case against our suspect keeps getting stronger.  The following is
an excerpt from a gdb session where I added to the breakpoint commands
printing the current buffer name and single-line C-level backtraces of
the threads when the main thread is current.  I also verified that the
position and distance that point jumped matched what I saw in *scratch*.

Thread 1 "find-file /scp:" hit Breakpoint 5, set_point_both (charpos=259, 
    bytepos=259) at intervals.c:1826
1826	{
$379 = (struct thread_state *) 0xd405a0 <main_thread>
"*scratch*"
"electric-indent-post-self-insert-function" (0xfffef670)
"self-insert-command" (0xfffef890)
"funcall-interactively" (0xfffef888)
"call-interactively" (0xfffefb70)
"command-execute" (0xfffefe28)

Thread 1 (Thread 0x7ffff7fc0b40 (LWP 15726)):
#0  set_point_both (charpos=259, bytepos=259) at intervals.c:1826

Thread 5 (Thread 0x7fffdbfff700 (LWP 15839)):
#0  0x00007ffff18e158f in pthread_cond_wait@@GLIBC_2.3.2 () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0

Thread 6 (Thread 0x7fffdb7fe700 (LWP 15840)):
#0  0x00007ffff18e158f in pthread_cond_wait@@GLIBC_2.3.2 () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0

Thread 7 (Thread 0x7fffdaffd700 (LWP 15841)):
#0  0x00007ffff18e158f in pthread_cond_wait@@GLIBC_2.3.2 () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0

Thread 8 (Thread 0x7fffda7fc700 (LWP 15842)):
#0  0x00007ffff18e158f in pthread_cond_wait@@GLIBC_2.3.2 () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0

Thread 9 (Thread 0x7fffd9ffb700 (LWP 15843)):
#0  0x00007ffff18e158f in pthread_cond_wait@@GLIBC_2.3.2 () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0

Thread 10 (Thread 0x7fffd97fa700 (LWP 15844)):
#0  0x00007ffff18e48cc in __lll_lock_wait () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0

Thread 11 (Thread 0x7fffd8ff9700 (LWP 15960)):
#0  0x00007ffff18e158f in pthread_cond_wait@@GLIBC_2.3.2 () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0
warning: Unknown thread 12
warning: Unknown thread 13
warning: Unknown thread 14
warning: Unknown thread 15
[Switching to Thread 0x7fffd97fa700 (LWP 15844)]

Thread 10 "find-file-nosel" hit Breakpoint 5, set_point_both (charpos=256, 
    bytepos=256) at intervals.c:1826
1826	{
$380 = (struct thread_state *) 0x38b3c80
"*scratch*"
"tramp-sh-handle-file-attributes" (0xd97f36e8)
"apply" (0xd97f36e0)
"tramp-sh-file-name-handler" (0xd97f3ac0)
"apply" (0xd97f3ab8)
"tramp-file-name-handler" (0xd97f49f8)
"file-attributes" (0xd97f4b28)
"tramp-handle-file-symlink-p" (0xd97f4e58)
"apply" (0xd97f4e50)
"tramp-sh-file-name-handler" (0xd97f5230)
"apply" (0xd97f5228)
"tramp-file-name-handler" (0xd97f6168)
"file-symlink-p" (0xd97f6310)
"tramp-sh-handle-file-truename" (0xd97f7be8)
"apply" (0xd97f7be0)
"tramp-sh-file-name-handler" (0xd97f7fc0)
"apply" (0xd97f7fb8)
"tramp-file-name-handler" (0xd97f8f28)
"file-truename" (0xd97f9308)
"find-file-noselect" (0xd97f9870)
0x38b0f10 PVEC_COMPILED

Thread 1 (Thread 0x7ffff7fc0b40 (LWP 15726)):
#0  0x00007ffff18e48cc in __lll_lock_wait () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0
#1  0x00007ffff18dda45 in pthread_mutex_lock () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0
#2  0x0000000000644109 in sys_mutex_lock (mutex=mutex@entry=0xd40560 <global_lock>) at systhread.c:137
#3  0x00000000006427f2 in acquire_global_lock (self=0xd405a0 <main_thread>) at thread.c:100
#4  really_call_select (arg=arg@entry=0x7ffffffeec00) at thread.c:582
#5  0x00000000005a6d78 in flush_stack_call_func (func=func@entry=0x642760 <really_call_select>, arg=arg@entry=0x7ffffffeec00) at alloc.c:5019
#6  0x0000000000643bb9 in thread_select (func=<optimized out>, max_fds=max_fds@entry=8, rfds=rfds@entry=0x7ffffffeece0, wfds=wfds@entry=0x7ffffffeed60, efds=efds@entry=0x0, timeout=timeout@entry=0x7ffffffef340, sigmask=0x0) at thread.c:602
#7  0x0000000000665a06 in xg_select (fds_lim=8, rfds=rfds@entry=0x7ffffffef440, wfds=wfds@entry=0x7ffffffef4c0, efds=efds@entry=0x0, timeout=timeout@entry=0x7ffffffef340, sigmask=sigmask@entry=0x0) at xgselect.c:117
#8  0x000000000061e708 in wait_reading_process_output (time_limit=time_limit@entry=30, nsecs=nsecs@entry=0, read_kbd=read_kbd@entry=-1, do_display=do_display@entry=true, wait_for_cell=..., wait_for_cell@entry=XIL(0), wait_proc=wait_proc@entry=0x0, just_wait_proc=0) at process.c:5384
#9  0x00000000004290f7 in sit_for (timeout=..., reading=reading@entry=true, display_option=display_option@entry=1) at dispnew.c:5810

Thread 5 (Thread 0x7fffdbfff700 (LWP 15839)):
#0  0x00007ffff18e158f in pthread_cond_wait@@GLIBC_2.3.2 () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0
#1  0x00000000006441c9 in sys_cond_wait (cond=cond@entry=0x38ced70, mutex=mutex@entry=0xd40560 <global_lock>) at systhread.c:163
#2  0x000000000064337f in lisp_mutex_lock_for_thread (mutex=0x38ced60, locker=0x38aec80, new_count=0) at thread.c:174
#3  0x0000000000643459 in lisp_mutex_lock (new_count=0, mutex=<optimized out>) at thread.c:189
#4  mutex_lock_callback (arg=<optimized out>) at thread.c:283
#5  0x00000000005a6d78 in flush_stack_call_func (func=func@entry=0x643440 <mutex_lock_callback>, arg=arg@entry=0x38ced50) at alloc.c:5019
#6  0x0000000000642db5 in Fmutex_lock (mutex=XIL(0x38ced55)) at thread.c:311
#7  0x00000000005cb72e in funcall_subr (subr=0xca94c0 <Smutex_lock>, numargs=numargs@entry=1, args=args@entry=0x7fffdbffce68) at eval.c:2897
#8  0x00000000005c9931 in Ffuncall (nargs=2, args=args@entry=0x7fffdbffce60) at eval.c:2822
#9  0x0000000000611040 in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=nargs@entry=3, args=<optimized out>, args@entry=0x3751848) at bytecode.c:632

Thread 6 (Thread 0x7fffdb7fe700 (LWP 15840)):
#0  0x00007ffff18e158f in pthread_cond_wait@@GLIBC_2.3.2 () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0
#1  0x00000000006441c9 in sys_cond_wait (cond=cond@entry=0x38ced70, mutex=mutex@entry=0xd40560 <global_lock>) at systhread.c:163
#2  0x000000000064337f in lisp_mutex_lock_for_thread (mutex=0x38ced60, locker=0x38afc80, new_count=0) at thread.c:174
#3  0x0000000000643459 in lisp_mutex_lock (new_count=0, mutex=<optimized out>) at thread.c:189
#4  mutex_lock_callback (arg=<optimized out>) at thread.c:283
#5  0x00000000005a6d78 in flush_stack_call_func (func=func@entry=0x643440 <mutex_lock_callback>, arg=arg@entry=0x38ced50) at alloc.c:5019
#6  0x0000000000642db5 in Fmutex_lock (mutex=XIL(0x38ced55)) at thread.c:311
#7  0x00000000005cb72e in funcall_subr (subr=0xca94c0 <Smutex_lock>, numargs=numargs@entry=1, args=args@entry=0x7fffdb7fc158) at eval.c:2897
#8  0x00000000005c9931 in Ffuncall (nargs=2, args=args@entry=0x7fffdb7fc150) at eval.c:2822
#9  0x0000000000611040 in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=nargs@entry=3, args=<optimized out>, args@entry=0x3751848) at bytecode.c:632

Thread 7 (Thread 0x7fffdaffd700 (LWP 15841)):
#0  0x00007ffff18e158f in pthread_cond_wait@@GLIBC_2.3.2 () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0
#1  0x00000000006441c9 in sys_cond_wait (cond=cond@entry=0x38ced70, mutex=mutex@entry=0xd40560 <global_lock>) at systhread.c:163
#2  0x000000000064337f in lisp_mutex_lock_for_thread (mutex=0x38ced60, locker=0x38b0c80, new_count=0) at thread.c:174
#3  0x0000000000643459 in lisp_mutex_lock (new_count=0, mutex=<optimized out>) at thread.c:189
#4  mutex_lock_callback (arg=<optimized out>) at thread.c:283
#5  0x00000000005a6d78 in flush_stack_call_func (func=func@entry=0x643440 <mutex_lock_callback>, arg=arg@entry=0x38ced50) at alloc.c:5019
#6  0x0000000000642db5 in Fmutex_lock (mutex=XIL(0x38ced55)) at thread.c:311
#7  0x00000000005cb72e in funcall_subr (subr=0xca94c0 <Smutex_lock>, numargs=numargs@entry=1, args=args@entry=0x7fffdaffb1b8) at eval.c:2897
#8  0x00000000005c9931 in Ffuncall (nargs=2, args=args@entry=0x7fffdaffb1b0) at eval.c:2822
#9  0x0000000000611040 in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=nargs@entry=3, args=<optimized out>, args@entry=0x3751848) at bytecode.c:632

Thread 8 (Thread 0x7fffda7fc700 (LWP 15842)):
#0  0x00007ffff18e158f in pthread_cond_wait@@GLIBC_2.3.2 () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0
#1  0x00000000006441c9 in sys_cond_wait (cond=cond@entry=0x38ced70, mutex=mutex@entry=0xd40560 <global_lock>) at systhread.c:163
#2  0x000000000064337f in lisp_mutex_lock_for_thread (mutex=0x38ced60, locker=0x38b1c80, new_count=0) at thread.c:174
#3  0x0000000000643459 in lisp_mutex_lock (new_count=0, mutex=<optimized out>) at thread.c:189
#4  mutex_lock_callback (arg=<optimized out>) at thread.c:283
#5  0x00000000005a6d78 in flush_stack_call_func (func=func@entry=0x643440 <mutex_lock_callback>, arg=arg@entry=0x38ced50) at alloc.c:5019
#6  0x0000000000642db5 in Fmutex_lock (mutex=XIL(0x38ced55)) at thread.c:311
#7  0x00000000005cb72e in funcall_subr (subr=0xca94c0 <Smutex_lock>, numargs=numargs@entry=1, args=args@entry=0x7fffda7fa1b8) at eval.c:2897
#8  0x00000000005c9931 in Ffuncall (nargs=2, args=args@entry=0x7fffda7fa1b0) at eval.c:2822
#9  0x0000000000611040 in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=nargs@entry=3, args=<optimized out>, args@entry=0x3751848) at bytecode.c:632

Thread 9 (Thread 0x7fffd9ffb700 (LWP 15843)):
#0  0x00007ffff18e158f in pthread_cond_wait@@GLIBC_2.3.2 () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0
#1  0x00000000006441c9 in sys_cond_wait (cond=cond@entry=0x38ced70, mutex=mutex@entry=0xd40560 <global_lock>) at systhread.c:163
#2  0x000000000064337f in lisp_mutex_lock_for_thread (mutex=0x38ced60, locker=0x38b2c80, new_count=0) at thread.c:174
#3  0x0000000000643459 in lisp_mutex_lock (new_count=0, mutex=<optimized out>) at thread.c:189
#4  mutex_lock_callback (arg=<optimized out>) at thread.c:283
#5  0x00000000005a6d78 in flush_stack_call_func (func=func@entry=0x643440 <mutex_lock_callback>, arg=arg@entry=0x38ced50) at alloc.c:5019
#6  0x0000000000642db5 in Fmutex_lock (mutex=XIL(0x38ced55)) at thread.c:311
#7  0x00000000005cb72e in funcall_subr (subr=0xca94c0 <Smutex_lock>, numargs=numargs@entry=1, args=args@entry=0x7fffd9ff91b8) at eval.c:2897
#8  0x00000000005c9931 in Ffuncall (nargs=2, args=args@entry=0x7fffd9ff91b0) at eval.c:2822
#9  0x0000000000611040 in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=nargs@entry=3, args=<optimized out>, args@entry=0x3751848) at bytecode.c:632

Thread 10 (Thread 0x7fffd97fa700 (LWP 15844)):
#0  set_point_both (charpos=256, bytepos=256) at intervals.c:1826
#1  0x0000000000631896 in set_point_from_marker (marker=...) at intervals.c:1771
#2  0x00000000005b82d5 in Fgoto_char (position=..., position@entry=XIL(0x7fffc000f4f5)) at editfns.c:423
#3  0x00000000005c2dc0 in save_excursion_restore (marker=XIL(0x7fffc000f4f5), window=...) at editfns.c:1023
#4  0x00000000005c9309 in unbind_to (count=<optimized out>, value=..., value@entry=XIL(0)) at eval.c:3593
#5  0x0000000000610fff in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=nargs@entry=1, args=<optimized out>, args@entry=0x373ca88) at bytecode.c:652
#6  0x00000000005ccfc2 in funcall_lambda (fun=XIL(0x7fffd97f3270), nargs=nargs@entry=1, arg_vector=0x373ca88, arg_vector@entry=0x7fffd97f36e8) at eval.c:3023
#7  0x00000000005c981b in Ffuncall (nargs=nargs@entry=2, args=args@entry=0x7fffd97f36e0) at eval.c:2836
#8  0x00000000005c9caf in Fapply (nargs=2, args=0x7fffd97f36e0) at eval.c:2399
#9  0x00000000005c9931 in Ffuncall (nargs=3, args=args@entry=0x7fffd97f36d8) at eval.c:2822

Thread 11 (Thread 0x7fffd8ff9700 (LWP 15960)):
#0  0x00007ffff18e158f in pthread_cond_wait@@GLIBC_2.3.2 () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0
#1  0x00000000006441c9 in sys_cond_wait (cond=cond@entry=0x1320fa0 <bss_sbrk_buffer+6162400>, mutex=mutex@entry=0xd40560 <global_lock>) at systhread.c:163
#2  0x000000000064337f in lisp_mutex_lock_for_thread (mutex=0x1320f90 <bss_sbrk_buffer+6162384>, locker=0x7fffbc061490, new_count=0) at thread.c:174
#3  0x0000000000643459 in lisp_mutex_lock (new_count=0, mutex=<optimized out>) at thread.c:189
#4  mutex_lock_callback (arg=<optimized out>) at thread.c:283
#5  0x00000000005a6d78 in flush_stack_call_func (func=func@entry=0x643440 <mutex_lock_callback>, arg=arg@entry=0x1320f80 <bss_sbrk_buffer+6162368>) at alloc.c:5019
#6  0x0000000000642db5 in Fmutex_lock (mutex=XIL(0x1320f85)) at thread.c:311
#7  0x00000000005cb72e in funcall_subr (subr=0xca94c0 <Smutex_lock>, numargs=numargs@entry=1, args=args@entry=0x7fffd8ff8710) at eval.c:2897
#8  0x00000000005c9931 in Ffuncall (nargs=2, args=args@entry=0x7fffd8ff8708) at eval.c:2822
#9  0x0000000000611040 in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., args_template@entry=XIL(0), nargs=nargs@entry=0, args=<optimized out>, args@entry=0x0) at bytecode.c:632
warning: Unknown thread 12
warning: Unknown thread 13
warning: Unknown thread 14
warning: Unknown thread 15