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

From: Gemini Lasswell <[email-masked]>
Date: Tue, 28 Aug 2018 12:48:28 -0700

Eli Zaretskii <[email-masked]> writes:

> I guess some code in the background thread calls a yielding function
> inside save-excursion or something?  I'd try running with a breakpoint
> in set_point_both and temp_set_point_both, with commands that show the
> backtrace and immediately continue the program.  Then you might see
> the culprit.

Here is an excerpt from my gdb output from following your instructions.
(I made the breakpoints conditional on the buffer being *scratch*.)  It
looks like your guess is correct, since there is a save-excursion in
tramp-sh-handle-file-attributes wrapping code that executes commands
on the remote machine.

Thread 1 "find-file /scp:" hit Breakpoint 4, set_point_both (charpos=195, 
    bytepos=195) at intervals.c:1826
1826	{
"electric-indent-post-self-insert-function" (0xf9420)
"self-insert-command" (0xf9620)
"funcall-interactively" (0xf9618)
"call-interactively" (0xf98f0)
"command-execute" (0xf9c08)
[Switching to Thread 0x7f1cad3e1700 (LWP 9151)]

Thread 5 "emacs" hit Breakpoint 4, set_point_both (charpos=146, bytepos=146)
    at intervals.c:1826
1826	{
"tramp-sh-handle-file-attributes" (0xad3db0b8)
"apply" (0xad3db1f0)
"tramp-sh-file-name-handler" (0xad3db498)
"apply" (0xad3db648)
"tramp-file-name-handler" (0xad3dc688)
"file-attributes" (0xad3dc7e0)
"tramp-check-cached-permissions" (0xad3dcbb0)
"tramp-sh-handle-file-readable-p" (0xad3dcff8)
"apply" (0xad3dcff0)
"tramp-sh-file-name-handler" (0xad3dd420)
"apply" (0xad3dd418)
"tramp-file-name-handler" (0xad3de458)
"file-readable-p" (0xad3de578)
"tramp-handle-file-accessible-directory-p" (0xad3de8f8)
"apply" (0xad3de8f0)
"tramp-sh-file-name-handler" (0xad3ded20)
"apply" (0xad3ded18)
"tramp-file-name-handler" (0xad3dfd58)
"file-accessible-directory-p" (0xad3dfec8)
"file-expand-wildcards" (0xad3e0218)
"find-file-noselect" (0xad3e07e0)
0x4867b10 PVEC_COMPILED

Thread 5 "emacs" hit Breakpoint 5, temp_set_point_both (
    buffer=0xdb5800 <bss_sbrk_buffer+458720>, charpos=charpos@entry=146, 
    bytepos=bytepos@entry=146) at intervals.c:1729
1729	{
"tramp-sh-handle-file-attributes" (0xad3db0b8)
"apply" (0xad3db1f0)
"tramp-sh-file-name-handler" (0xad3db498)
"apply" (0xad3db648)
"tramp-file-name-handler" (0xad3dc688)
"file-attributes" (0xad3dc7e0)
"tramp-check-cached-permissions" (0xad3dcbb0)
"tramp-sh-handle-file-readable-p" (0xad3dcff8)
"apply" (0xad3dcff0)
"tramp-sh-file-name-handler" (0xad3dd420)
"apply" (0xad3dd418)
"tramp-file-name-handler" (0xad3de458)
"file-readable-p" (0xad3de578)
"tramp-handle-file-accessible-directory-p" (0xad3de8f8)
"apply" (0xad3de8f0)
"tramp-sh-file-name-handler" (0xad3ded20)
"apply" (0xad3ded18)
"tramp-file-name-handler" (0xad3dfd58)
"file-accessible-directory-p" (0xad3dfec8)
"file-expand-wildcards" (0xad3e0218)
"find-file-noselect" (0xad3e07e0)
0x4867b10 PVEC_COMPILED
[Switching to Thread 0x7f1cc590db40 (LWP 8465)]

Thread 1 "find-file /scp:" hit Breakpoint 4, set_point_both (charpos=147, 
    bytepos=147) at intervals.c:1826
1826	{
"electric-indent-post-self-insert-function" (0xf9420)
"self-insert-command" (0xf9620)
"funcall-interactively" (0xf9618)
"call-interactively" (0xf98f0)
"command-execute" (0xf9c08)