Subject: RE: Cygwin commands are intermittently hanging on Windows
From: Brian Inglis <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Fri, 25 Nov 2022 14:54:30 -0700
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>

On Wed, 16 Nov 2022 17:19:22 +0000, Derek Pagel wrote:
> We've recreated the hanging issue on Windows 2019 and were able to capture 
> and attach a DMP file of a 'cp' command that was hanging. One other thing 
> that we noticed is that the Cygwin commands each tend to hang about 42 or 43
> seconds.
So the commands are not hanging, they are slowed down, or delayed by 40 seconds.
That sounds like the common symptoms of long/large queries/responses to/from a 
network server, usually a DC, often for AD info, or a slow network connection to 
a DC or AD server, or possibly a slow SMB or NFS file server.

If you are exec-ing each Cygwin command from a non-Cygwin process, that will 
require setting up the Cygwin environment, including possibly long searches 
through your AD each time for all group memberships.

See:	https://cygwin.com/cygwin-ug-net/ntsec.html

The solution is usually to run the Cygwin cygserver daemon at system startup to 
preload, cache, and share AD entries and other info across Cygwin processes.

See:	https://cygwin.com/faq/faq.html#faq.using.startup-slow

You can provide confirmation or more information on the low level causes by 
running the slow command from strace e.g. "strace -o cp.strace cp ..." and 
providing the cp.strace output as a *TEXT* attachment to a reply post.

Long PATH lists, especially with network shares, can also slow down searches for 
executable binaries, as can home directories or configuration files on shares.
Setting Cygwin PATH to minimal $HOME/bin:/usr/local/bin:/usr/bin:/bin assuming 
those exist and are not on the network reduces searches.

It is also possible that a less optimal AV is doing something on every Cygwin 
process start, or some process is intercepting DLLs, which may slow down processes.
Run cygcheck cp to see if anything other than cygwin and standard Windows base 
system32 DLLs from standard locations are being loaded.
Check to see if any AV product you are running is chewing up a lot of time on 
the system while you are running Cygwin commands.

See:	https://cygwin.com/faq/faq.html#faq.using.bloda

Windows system DMPs are not useful for diagnosing problems with Cygwin 
multithreaded processes.
You could see if you can find anyone who could diagnose what Windows was doing 
during those 40 second periods from the DMP as a cross-check.

-- 
Take care. Thanks, Brian Inglis			Calgary, Alberta, Canada

La perfection est atteinte			Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter	not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer	but when there is no more to cut
			-- Antoine de Saint-Exupéry

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple