Subject: bug#36090: 26.1; Tramp hanging when writing version-controlled file

From: Michael Albinus <[email-masked]>
Date: Wed, 05 Jun 2019 11:47:17 +0200

Norman Gray <[email-masked]> writes:

Hi Norman,

thanks for your comprehensive bug report!

>      $ cd checkouts/itm
>      $ mkdir test
>      $ cd test
>      $ hg init
>      $ echo hello >hello.txt
>      $ hg add
>      $ hg ci -m"Initial version"
>      $ echo second >second.txt

I have followed exactly your recipe on my Ubuntu 19.04 machine. It runs

--8<---------------cut here---------------start------------->8---
GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.7)
 of 2019-04-11, modified by Debian
--8<---------------cut here---------------end--------------->8---

I have started "/usr/bin/emacs -Q", in order to avoid any interference.

> Then open /scp:helium:checkouts/itm/test/hello.txt (the remote machine
> is called `helium` in this case):
>
>      Tramp: Inserting
> ‘/scp:helium:/home/norman/checkouts/itm/test/hello.txt’...
>      Tramp: Encoding remote file
> ‘/scp:helium:/home/norman/checkouts/itm/test/hello.txt’ with
> ‘openssl enc -base64 <%s’...done
>      Tramp: Decoding local file
> ‘/var/folders/f5/vh0d0ls94_j5s4bv49sz90s40000gn/T/tramp.w8WmcP.txt’
> with ‘base64-decode-region’...done
>      Tramp: Inserting
> ‘/scp:helium:/home/norman/checkouts/itm/test/hello.txt’...done
>
> Then it hangs.  I `C-g`, and then get:
>
>      Tramp: Checking ‘vc-registered’ for
> /scp:helium:/home/norman/checkouts/itm/test/hello.txt...done
>      Tramp: Inserting
> ‘/scp:helium:/home/norman/checkouts/itm/test/hello.txt’...done

For me, it runs through:

--8<---------------cut here---------------start------------->8---
Tramp: Opening connection for localhost using scp...
Tramp: Sending command ‘exec ssh   -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none localhost’
Tramp: Waiting for prompts from remote shell...done
Tramp: Found remote shell prompt on ‘localhost’
Tramp: Opening connection for localhost using scp...done
Tramp: Inserting ‘/scp:localhost:/home/albinus/tmp/36090/hello.txt’...
Tramp: Encoding remote file ‘/scp:localhost:/home/albinus/tmp/36090/hello.txt’ with ‘base64 <%s’...done
Tramp: Decoding local file ‘/tmp/tramp.3Dk3y9.txt’ with ‘base64-decode-region’...done
Tramp: Inserting ‘/scp:localhost:/home/albinus/tmp/36090/hello.txt’...done

Tramp: Checking ‘vc-registered’ for /scp:localhost:/home/albinus/tmp/36090/hello.txt...done
Tramp: Inserting ‘/scp:localhost:/home/albinus/tmp/36090/hello.txt’...done
--8<---------------cut here---------------end--------------->8---

I have used /scp:localhost:, because there's no other machine around
with installed Mercurial.

> I make a change to the file, and save it:
>
> Saving file /scp:helium:/home/norman/checkouts/itm/test/hello.txt...
>
>      Tramp: Checking ‘vc-registered’ for
> /scp:helium:/home/norman/checkouts/itm/test/hello.txt...
>      Tramp: Opening connection for helium using scp...
>      Tramp: Sending command ‘exec ssh   -o ControlMaster=auto -o
> ControlPath='tramp.%C' -o ControlPersist=no -e none helium’
>      Tramp: Waiting for prompts from remote shell...done
>      Tramp: Found remote shell prompt on ‘helium’
>      Tramp: Opening connection for helium using scp...done
>      Tramp: Checking ‘vc-registered’ for
> /scp:helium:/home/norman/checkouts/itm/test/hello.txt...done
>      Saving file
> /scp:helium:/home/norman/checkouts/itm/test/hello.txt...
>      Tramp: Encoding local file
> ‘/var/folders/f5/vh0d0ls94_j5s4bv49sz90s40000gn/T/tramp.dMysF4.txt’
> using ‘base64-encode-region’...done
>      Tramp: Decoding remote file
> ‘/scp:helium:/home/norman/checkouts/itm/test/hello.txt’ using
> ‘openssl enc -d -base64 >%s’...done
>
> It hangs again.  Again `C-g`, then:
>
>      Wrote /scp:helium:/home/norman/checkouts/itm/test/hello.txt
>      Quit

Also no problem here:

--8<---------------cut here---------------start------------->8---
Saving file /scp:localhost:/home/albinus/tmp/36090/hello.txt...
Tramp: Encoding local file ‘/tmp/tramp.nN5pim.txt’ using ‘base64-encode-region’...done
Tramp: Decoding remote file ‘/scp:localhost:/home/albinus/tmp/36090/hello.txt’ using ‘base64 -d -i >%s’...done
Wrote /scp:localhost:/home/albinus/tmp/36090/hello.txt
--8<---------------cut here---------------end--------------->8---

> The file does save successfully.  Thus the hang/wait is happening after
> the
> file has been saved to the remote machine's disk

Well, I haven't used a higher tramp-verbose level, so there are less
messages. But it looks like the problem is in vc-registered (ie,
tramp-sh-handle-vc-registered in Tramp). This is called after the file
is saved.

> If I create a non-version-controlled file `second.txt` beside this, and
> try to open, then save, this file using Tramp, this works as expected.
> That is, version-controlled hello.txt works; non-controlled second.txt
> doesn't.

sigh.

> The messages above and below are with tramp-verbose set to 3.  I don't
> get anything significantly different that I can see, with tramp-verbose
> set to 10.

Tramp doesn't write more verbose output to the *Messages* buffer. But if
you increase tramp-verbose to greater than 3, a Tramp debug buffer
*debug tramp/scp helium* will appear, which tells us everything.

> I can see some discussion of what may be this problem from 2014
> <https://lists.gnu.org/archive/html/bug-gnu-emacs/2014-10/msg01232.html>,
> but that thread appears to suggest that the fix is already committed
> (five years ago!).

Doesn't look related, but who knows...

> The same happens when starting Emacs with option -Q.

As said above, it works for me.

> Let me know if there's anything I can add.

Please rerun your test with tramp-verbose 10. Show the debug
buffer. Wait a little bit before you quit via C-g, in order to see it in
the traces when it happens.

> Best wishes,
> Norman

Best regards, Michael.