[PATCH] Cygwin: console: Fix segfault on shared_console_info access.

Brian Inglis Brian.Inglis@SystematicSw.ab.ca
Mon Feb 24 21:08:00 GMT 2020


On 2020-02-24 11:33, Corinna Vinschen wrote:
> On Feb 25 01:10, Takashi Yano wrote:
>> On Mon, 24 Feb 2020 11:08:35 +0100
>> Corinna Vinschen wrote:
>> [...]
>>> Btw., are you testing the console with black background?  I'm asking
>>> because I'm using the console with grey background and black characters,
>>> and I'm always seeing artifacts when using vim in xterm mode.
>>>
>>> E.g., open vim on the fork-setsid.c source in the console in xterm
>>> mode.  Move the cursor to the beginning of the word `setsid'.  Now
>>> press the three chars
>>>
>>>   c h <CR>
>>>
>>> this moves the setsid call to the next line.  But it also adds
>>> black background after `setsid();'.  Simiar further actions always
>>> create black background artifacts.
>>>
>>> Is there anything we can do against that?
>>
>> This seems to be a bug of windows console. It also occurs in wsl.
>> /bin/echo -e '\033[H\033[5L'
>> causes the similar result.
> 
> Oh well.
> 
>> The following code cause the problem as well.
>>
>> #include <windows.h>
>> int main()
>> {
>>     CONSOLE_SCREEN_BUFFER_INFO sbi;
>>     SMALL_RECT r;
>>     COORD c = {0, 0};
>>     CHAR_INFO f = {' ', 0};
>>     HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
>>     DWORD n;
>>     ReadConsoleOutputAttribute(h, &f.Attributes, 1, c, &n);
>>     GetConsoleScreenBufferInfo(h, &sbi);
>>     c.X = 0;
>>     c.Y = sbi.srWindow.Top + 5;
>>     ScrollConsoleScreenBuffer(h, &sbi.srWindow, NULL, c, &f);
>>     return 0;
>> }
> 
> Is there some kind of workaround for that problem?  Otherwise defaulting
> to a (broken) xterm mode instead of a (working) cygwin mode is a bit
> questionable, isn't it?

I'm a windows with white backgrounds user and e.g. vim in latest Cygwin under
cmd requires typing ctrl-L to refresh the screen every couple of commands or
motions; looks okay under mintty in windows with white backgrounds.

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

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.



More information about the Cygwin-patches mailing list