Windows 10 and cygwin hanging issue

2

When I run an interactive program (mysql for example) from cygwin on Windows 10 the input just hangs there and doesn't do anything. If I ctrl-c out I can see the input get sent to the console.

I'm also seeing weird results from other interactive programs (pry, irb) - everything was working fine on Windows 7.

Has anyone seen this and solved it?

pguardiario

Posted 2016-08-11T02:08:09.990

Reputation: 131

1I've had a similar issue where mintty hung on exit, but only when launched via shortcut (as opposed to launching from chere). The root cause was that mintty needed to be launched as an administrator. Updating my shortcuts to include the "Run as administrator" option fixed it for me. – Mr. Llama – 2018-04-23T16:44:31.947

Answers

3

In the cygwin environment the linux command 'strace' is available. strace outputs all the OS <--> application interactions (in this case, application <--> cygwin <--> OS), and the specific system call or other operation that it is freezing on should be apparent.

To use strace you simply prepend the strace command before the command that launches the application you want to debug. For example if you are launching mysql from the cygwin terminal using the command mysql, call it instead as strace mysql.

If the output from running strace on the freezing programs isn't apparent, please post the output to pastebin or equivalent (don't try to add to your answer, it will be a huge amount of text).

The next step would be to run it with a debugger such as gdb, but in a case like this strace is usually sufficient.

Update

Apparently there is was a bug introduced in the cygwin port of strace in the last couple months; per a google search of 'cygwin strace seg fault'; I wasn't aware of that. Since strace is the best tool for this job, try updating your cygwin installation to see if a fix was intentionally or inadvertently introduced. To update your cygwin installation, you use the following command sequence:

wget -NP /usr/local/bin/ http://cygwin.com/setup-x86_64.exe
chmod u+x /usr/local/bin/setup-x86_64.exe
/usr/local/bin/setup-x86_64.exe -n

Source

After updating, try again. If it still segfaults, things get a little messier as gdb is far less easy to use, and there are no real equivalents to strace available in the cygwin environment that I am currently aware of.

There is always the chance that the update will address your launching issues, and strace becomes a moot point (not a very big chance...)

Update 2

If the cygwin strace command segfaults after update, I think your best bet is to use a native windows user space debugger such as logger.exe. Installation information can be found here.

logger.exe is used in a similar way to strace, the problem being that you will now have cygwins translations of the programs system calls exposed, not the actual system calls. In other words, it will only be looking at the OS to cygwin interactions, and the specifics of the offending program may be obfuscated. However a hang or freeze can almost always be attributed to either a resource limitation or a unresponsive system call, and this method will expose that.

Since I'm offering this as an alternative to something (strace) that might still work after the update, I'm not going to go into great detail into the specific usage of it. Basically what you will do (post installation), is call cygwin from a windows command prompt prepended by the logger.exe program, just as I described strace. An interactive cygwin terminal will then open and you need to launch the program you are evaluating from that. An enormous amount of text (should) be output by the logger application describing what cygwin, and it's child process "your program", are doing. When a hang occurs, the specific system call or resource being waited on should be apparent. Again, if its not, post the full text of the logger output.

Argonauts

Posted 2016-08-11T02:08:09.990

Reputation: 4 000

When I run strace mysql I just see: Segmentation fault – pguardiario – 2016-08-11T02:50:41.430

That is the entire output? Not a single character besides that? – Argonauts – 2016-08-11T03:01:54.533

That's correct. – pguardiario – 2016-08-11T03:25:57.633

See my update; a little googling showed that it is (or hopefully) was a common issue. My skepticism comes from the fact that strace outputs an obnoxious amount of text when using it, so having the opposite occur seemed incredulous. – Argonauts – 2016-08-11T03:31:08.917

This is actually a brand new cygwin environment that I'm setting up today, so everything is up to date. I think I'm going to wait and see if someone else has already solved this, I can use cmd.exe in the meantime. – pguardiario – 2016-08-11T03:39:22.103

I don't blame you there; strace would have been easy, alternatives are messy. In any event, consider using Bash for Windows instead; it's a far more optimized environment - no translation layer, and provides compatibility with native linux binaries - http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/

– Argonauts – 2016-08-11T03:45:39.837

Thanks for the tip, I never heard of that feature, it might be just the thing. – pguardiario – 2016-08-11T06:00:29.967

3

If strace is segfaulting the most likely cause is an Antivirus.

The most recent one causing this problem is the Micro Trend

https://cygwin.com/ml/cygwin/2016-08/msg00092.html

Several cases were reported for it in the last month

matzeri

Posted 2016-08-11T02:08:09.990

Reputation: 1 662

I should have guessed that - these antivirus suites are becoming more of a problem than the viruses and malware they do a bad job of protecting people from. – Argonauts – 2016-08-11T17:09:52.160