bug#38079: On Windows tramp hangs after server-start is called

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

Wanrong Lin-2
On Windows, after M-x server-start, tramp no longer works. When I tried
to connect to a "pscp" remote Linux host, it just hangs at the message
"Remote prompt found" (something like that).

Today I finally figured out what the problem is, and put in a work
around as following:

;; On Windows, after "server-start" is called, somehow (system-name)
will return lower case host name. If the original
;; (system-name) returns upper case host name now
tramp-restricted-shell-hosts-alist will be out-of-date and cause
;; tramp not to function properly.
(defadvice server-start (after update-restricted-host-list last activate)
   (setf tramp-restricted-shell-hosts-alist
         (when (memq system-type '(windows-nt))
           (list (concat "\\`" (regexp-quote (system-name)) "\\'")))))

But the proper fix should be to make sure (system-name) always returns
the same string consistently. I found it is this sexp in "server-start"
function that changes the return value of (system-name):

       (setq server-process
         (apply #'make-network-process ....))

This bug has bothered me for a long time. Even Emacs 26.3 still has it
(although I am still using 26.2 for daily work). I hope this can lead to
a fix that saves some frustration for other fellow Emacs users.

Here is my set up:

In GNU Emacs 26.2 (build 1, x86_64-w64-mingw32)
  of 2019-04-13 built on CIRROCUMULUS
Repository revision: fd1b34bfba8f3f6298df47c8e10b61530426f749

Warren




Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

Eli Zaretskii
> From: Wanrong Lin <[hidden email]>
> Date: Tue, 5 Nov 2019 19:52:59 -0500
>
> ;; On Windows, after "server-start" is called, somehow (system-name)
> will return lower case host name. If the original
> ;; (system-name) returns upper case host name now
> tramp-restricted-shell-hosts-alist will be out-of-date and cause
> ;; tramp not to function properly.
> (defadvice server-start (after update-restricted-host-list last activate)
>    (setf tramp-restricted-shell-hosts-alist
>          (when (memq system-type '(windows-nt))
>            (list (concat "\\`" (regexp-quote (system-name)) "\\'")))))
>
> But the proper fix should be to make sure (system-name) always returns
> the same string consistently. I found it is this sexp in "server-start"
> function that changes the return value of (system-name):
>
>        (setq server-process
>          (apply #'make-network-process ....))

Thanks.  However, your proposed solution is very hard to implement
(for boring technical reasons), so my suggestion is for Trump to
compare system names case insensitively, at least on MS-Windows, with
a proper comment to explain why.



Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

martin rudalics
 > (for boring technical reasons), so my suggestion is for Trump to
                                                             ^

 > compare system names case insensitively, at least on MS-Windows, with

So Richard was right after all when he suggested to rename this ...

martin



Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

Wanrong Lin-2
In reply to this post by Eli Zaretskii
Yes that can be another way to fix. The downside is we don't know this
system-name upper/lower case change will cause any surprises somewhere
else. But I don't understand the underlying difficulty to ensure
system-name never changes. Thanks for fixing it either way.

Warren

On 11/6/2019 11:06 AM, Eli Zaretskii wrote:

>> From: Wanrong Lin <[hidden email]>
>> Date: Tue, 5 Nov 2019 19:52:59 -0500
>>
>> ;; On Windows, after "server-start" is called, somehow (system-name)
>> will return lower case host name. If the original
>> ;; (system-name) returns upper case host name now
>> tramp-restricted-shell-hosts-alist will be out-of-date and cause
>> ;; tramp not to function properly.
>> (defadvice server-start (after update-restricted-host-list last activate)
>>     (setf tramp-restricted-shell-hosts-alist
>>           (when (memq system-type '(windows-nt))
>>             (list (concat "\\`" (regexp-quote (system-name)) "\\'")))))
>>
>> But the proper fix should be to make sure (system-name) always returns
>> the same string consistently. I found it is this sexp in "server-start"
>> function that changes the return value of (system-name):
>>
>>         (setq server-process
>>           (apply #'make-network-process ....))
> Thanks.  However, your proposed solution is very hard to implement
> (for boring technical reasons), so my suggestion is for Trump to
> compare system names case insensitively, at least on MS-Windows, with
> a proper comment to explain why.





Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

Michael Albinus
In reply to this post by martin rudalics
martin rudalics <[hidden email]> writes:

>> (for boring technical reasons), so my suggestion is for Trump to
>                                                             ^
>
>> compare system names case insensitively, at least on MS-Windows, with
>
> So Richard was right after all when he suggested to rename this ...

... and I've refused, for good reasons.

Will see what I could do.

> martin

Best regards, Michael.



Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

Eli Zaretskii
In reply to this post by Wanrong Lin-2
> Cc: [hidden email]
> From: Wanrong Lin <[hidden email]>
> Date: Wed, 6 Nov 2019 11:50:59 -0500
>
> But I don't understand the underlying difficulty to ensure
> system-name never changes.

There are two system calls that return this information on Windows,
and they treat the letter-case differently.  The second system call
needs the winsock layer to be initialized, and we don't want to do
that at startup because it causes various problems (sorry, I no longer
remember the details of that part).  So we only call the network-aware
system call after some network connection is available.



Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

Michael Albinus
In reply to this post by Wanrong Lin-2
Wanrong Lin <[hidden email]> writes:

Hi,

> Yes that can be another way to fix. The downside is we don't know this
> system-name upper/lower case change will cause any surprises somewhere
> else. But I don't understand the underlying difficulty to ensure
> system-name never changes. Thanks for fixing it either way.

Does the appended patch fix the problem for you?

> Warren

Best regards, Michael.


attachment0 (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

Wanrong Lin-2
Yes it does. Thanks.

Wanrong

On 11/7/2019 10:23 AM, Michael Albinus wrote:

> Wanrong Lin <[hidden email]> writes:
>
> Hi,
>
>> Yes that can be another way to fix. The downside is we don't know this
>> system-name upper/lower case change will cause any surprises somewhere
>> else. But I don't understand the underlying difficulty to ensure
>> system-name never changes. Thanks for fixing it either way.
> Does the appended patch fix the problem for you?
>
>> Warren
> Best regards, Michael.
>




Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

Wanrong Lin-2
In reply to this post by Michael Albinus
Yes it does. Thanks.

Warren

On 11/7/2019 10:23 AM, Michael Albinus wrote:

> Wanrong Lin <[hidden email]> writes:
>
> Hi,
>
>> Yes that can be another way to fix. The downside is we don't know this
>> system-name upper/lower case change will cause any surprises somewhere
>> else. But I don't understand the underlying difficulty to ensure
>> system-name never changes. Thanks for fixing it either way.
> Does the appended patch fix the problem for you?
>
>> Warren
> Best regards, Michael.
>




Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

Michael Albinus
In reply to this post by Wanrong Lin-2
Version: 27.1

Wanrong Lin <[hidden email]> writes:

> Yes it does. Thanks.

Thanks for the feedback. I've committed the patch to the repositories,
closing the bug.

> Wanrong

Best regards, Michael.



Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

Michael Albinus
In reply to this post by Eli Zaretskii
Eli Zaretskii <[hidden email]> writes:

>> But I don't understand the underlying difficulty to ensure
>> system-name never changes.
>
> There are two system calls that return this information on Windows,
> and they treat the letter-case differently.  The second system call
> needs the winsock layer to be initialized, and we don't want to do
> that at startup because it causes various problems (sorry, I no longer
> remember the details of that part).  So we only call the network-aware
> system call after some network connection is available.

Shouldn't we document this in etc/PROBLEMS? I can't write this, because
I don't know too much about Emacs on MS Windows.

Best regards, Michael.



Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

Eli Zaretskii
> From: Michael Albinus <[hidden email]>
> Cc: Wanrong Lin <[hidden email]>,  [hidden email]
> Date: Fri, 08 Nov 2019 08:51:42 +0100
>
> Eli Zaretskii <[hidden email]> writes:
>
> >> But I don't understand the underlying difficulty to ensure
> >> system-name never changes.
> >
> > There are two system calls that return this information on Windows,
> > and they treat the letter-case differently.  The second system call
> > needs the winsock layer to be initialized, and we don't want to do
> > that at startup because it causes various problems (sorry, I no longer
> > remember the details of that part).  So we only call the network-aware
> > system call after some network connection is available.
>
> Shouldn't we document this in etc/PROBLEMS?

What would you suggest to document?  This is an internal detail of the
Emacs implementation, and users have no control on the results.  Maybe
I'm missing something, but what useful workarounds can we suggest?



Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

Michael Albinus
Eli Zaretskii <[hidden email]> writes:

>> > There are two system calls that return this information on Windows,
>> > and they treat the letter-case differently.  The second system call
>> > needs the winsock layer to be initialized, and we don't want to do
>> > that at startup because it causes various problems (sorry, I no longer
>> > remember the details of that part).  So we only call the network-aware
>> > system call after some network connection is available.
>>
>> Shouldn't we document this in etc/PROBLEMS?
>
> What would you suggest to document?  This is an internal detail of the
> Emacs implementation, and users have no control on the results.  Maybe
> I'm missing something, but what useful workarounds can we suggest?

I don't speak about users but developers. At least we shall warn them
that `system-name' can return different values. They might apply counter
measures, like using only (downcase (system-name)) or a alike on w32.

Well, since it is about developers, the Lisp manual might be the better
place to document, in the "Operating System Environment" section.

Best regards, Michael.



Reply | Threaded
Open this post in threaded view
|

bug#38079: On Windows tramp hangs after server-start is called

Eli Zaretskii
> From: Michael Albinus <[hidden email]>
> Cc: [hidden email],  [hidden email]
> Date: Fri, 08 Nov 2019 11:50:45 +0100
>
> >> Shouldn't we document this in etc/PROBLEMS?
> >
> > What would you suggest to document?  This is an internal detail of the
> > Emacs implementation, and users have no control on the results.  Maybe
> > I'm missing something, but what useful workarounds can we suggest?
>
> I don't speak about users but developers.

Then PROBLEMS is not the appropriate place.

> At least we shall warn them that `system-name' can return different
> values. They might apply counter measures, like using only (downcase
> (system-name)) or a alike on w32.
>
> Well, since it is about developers, the Lisp manual might be the better
> place to document, in the "Operating System Environment" section.

Right.  Or maybe in the doc string.