Problems with a combination of a mingw program, mintty, and CYGWIN=disable_pcon

André Bleau Andre_Bleau@hotmail.com
Thu May 7 03:38:25 GMT 2020


Hi cygwin users,

I have cli program that I run with mintty. It is a simple C++ program, reading from cin and outputing to cout. It is cross-compiled as a mingw program. I've been running it without problems fro over 2 years. Recently, I updated cygwin to 3.1.4-1 and noticed the pcon support. Since then, the output of my program has been messy: output lines have intermittent gaps in them. I made a simple test case that reproduces the problem, from the following simple C++ file, hello.cpp :

#include <iostream>
using namespace std;
static string Green		= "\033[32m";
static string Yellow	= "\033[33m";
static string Reset		= "\033[0m";
int main (int pArgc, char* pArgv[])
{
	cout << "Hello!" << endl;
	string answer;
	do
	{
		cout << Yellow << "q to Quit, p to Print " << Reset;
		cin >> answer;
		cout << Yellow << "You answered: " << Reset << answer << endl;
		if (answer[0] == 'p')
		{
			for (int i = 0; i < 30; ++i)
			{
				cout << Green << i << "\tA simple line of printing in green characters." << Reset << endl;
			}
		}
	} while (answer[0] != 'q');
	cout << "Goodbye." << endl;
	return 0;
}

Compiled with:
x86_64-w64-mingw32-c++ -g hello.cpp -o hello -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic

When run in mintty, it prompts you to answer q or p . q quits the program, p prints 30 times the same line of green text. 

With the new pcon support, often, everything is correct: 30 lines of green text are outputted correctly; but most of the time a few lines will have gaps in them or show a partial escape sequence, like this:

You answered: p
0  A simple line of printing in green characters.
1  A simple line of printing in green characters.
2  A simple line of printing in green characters.
3  A simple line of printing in green characters.
4  A simple line of printing in green characters.
5  A simple line of printing in green characters.
6  A simple line of printing in green characters.
7  A simple line of printing in green characters.
8  A simple line of printing in green characters.
9  A simple line of printing in green characters.
10 A simple line of printing in green characters.
11 A simple line of printing in green characters.
12 A simple line of printing in green characters.
13 A simple line of printing in green characters.
14 A simple line of printing in green characters.
15 A simple line of printing in green characters.
16 A simple line of printing in green characters.
17 A simple line of printing in green characters.
18 A simple line of printing in green characters.
19 A simple line of printing in green characters.
20 A simple line of printing in green characters.
21 A simple line of printing in green characters.
22 A simple line of printing in green characters.
23 A simple line of printing in green characters.
24 A simple line of printing in green characters.
25 A simple line of printing in green characters.
26 A simple line of printing in green characters.
27 A simple line of printing in green characters.
28 A simple line of printing in green characters.
 [32m29 A simple line of printing in green characters.
q to Quit, p to Print          p
You answered: p
0  A simple line of printing in green characters.
1  A simple line of printing in green characters.
2  A simple line of printing in green characters.
3  A simple line of printing in green characters.
4  A simple line of printing in green characters.
5  A simple line of printing in green characters.
6  A simple line of printing in green characters.
7  A simple line of printing in green characters.
8  A simple line of printing in green characters.
9  A simple line of printing in green characters.
10 A simple line of printing in green characters.
11 A simple line of printing in green characters.
12 A simple line of printing in green characters.
13 A simple line of printing in green characters.
14 A simple line of printing in green characters.
15 A simple line of printing in green characters.
16 A simple line of printing in green characters.
17 A simple line of printing in green characters.
18 A simple line of printing in green characters.
19 A simple line of printing in green characters.
20 A simple line of printing in green characters.
21 A simple line of printing in green characters.
22 A simple line of printing in green characters.
23 A simple line of printing in green characters.
24 A simple line of printing in green characters.
25 A simple line of printing in green characters.
26 A simple line of printing in green characters.
27 A simple line of printing in green characters.
28 A simple line of printing in green characters.
     29 A simple line of printing in green characters.
q to Quit, p to Print          q


If I start mintty with CYGWIN=disable_pcon and run the hello program in it, everything is fine and the program always outputs correctly, as it did before I updated cygwin.

CYGWIN=disable_pcon /usr/bin/mintty &

OK, no big deal then, I'll make a small bash script to automate this: hellobash

#/bin/bash
CYGWIN=disable_pcon /usr/bin/mintty absolutePath/hello.exe &

This is where it gets weird. Running ./hellobash sometimes gets the hello program run correctly. It accepts input and displays output as expected. But in about 1 in 5 runs, it will not accept input. A prompt is displayed, but no cursor is shown and typing produces nothing.  ^C does not stop the program. Weirder: in about 1 in 20 to 30 runs, it's the converse: it will be stuck in a loop as if input was continuously feed to it, even if you don't type anything.

Output of cygcheck -c is attached.

Regards,

- André Bleau



-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 29851 bytes
Desc: cygcheck.out
URL: <https://cygwin.com/pipermail/cygwin/attachments/20200507/d510b023/attachment-0001.obj>


More information about the Cygwin mailing list