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

From: Eli Zaretskii <[email-masked]>
Date: Fri, 31 Aug 2018 09:40:57 +0300

> From: Gemini Lasswell <[email-masked]>
> Cc: [email-masked]
> Date: Thu, 30 Aug 2018 11:49:27 -0700
> 
> Printing the C-level backtraces on every breakpoint makes Emacs under
> gdb too slow to let me reproduce the bug, so I came up with this
> compromise:
> 
> break set_point_both if current_thread->m_current_buffer == $1
> commands
> p current_thread
> xbacktrace
> if current_thread != &main_thread
>   thread apply 1 5-15 backtrace

The "backtrace" command accepts an argument, the number of frames to
show; so you could use "backtrace 10" to show just the innermost 10
frames, and thus make the backtrace be faster.

> Thread 1 (Thread 0x7f873eb61b40 (LWP 27888)):
> #0  0x00007f87384808cc in __lll_lock_wait () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0
> #1  0x00007f8738479a45 in pthread_mutex_lock () from /nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/libpthread.so.0
> #2  0x0000000000648df9 in sys_mutex_lock (mutex=mutex@entry=0xd455c0 <global_lock>) at systhread.c:137
> #3  0x0000000000647582 in acquire_global_lock (self=0xd45600 <main_thread>) at thread.c:100

This thread, the main thread, is waiting for the global lock to become
free.

> Thread 5 (Thread 0x7f8722610700 (LWP 27981)):
> #0  set_point_both (charpos=146, bytepos=146) at intervals.c:1826
> #1  0x0000000000635f08 in set_point_from_marker (marker=..., marker@entry=XIL(0x3e59fc5)) at intervals.c:1771
> #2  0x00000000005bbf32 in Fgoto_char (position=..., position@entry=XIL(0x3e59fc5)) at editfns.c:423
> #3  0x00000000005c6920 in save_excursion_restore (marker=XIL(0x3e59fc5), window=...) at editfns.c:1023
> #4  0x00000000005cce89 in unbind_to (count=<optimized out>, value=..., value@entry=XIL(0)) at eval.c:3593

This thread is restoring point as part as returning from
save-excursion.  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.