| 1 |
/* |
| 2 |
* Demonstrates a conhost hang that occurs when widening the console buffer |
| 3 |
* while selection is in progress. The problem affects the new Windows 10 |
| 4 |
* console, not the "legacy" console mode that Windows 10 also includes. |
| 5 |
* |
| 6 |
* First tested with: |
| 7 |
* - Windows 10.0.10240 |
| 8 |
* - conhost.exe version 10.0.10240.16384 |
| 9 |
* - ConhostV1.dll version 10.0.10240.16384 |
| 10 |
* - ConhostV2.dll version 10.0.10240.16391 |
| 11 |
*/ |
| 12 |
|
| 13 |
#include <windows.h> |
| 14 |
#include <stdio.h> |
| 15 |
#include <stdlib.h> |
| 16 |
#include <wchar.h> |
| 17 |
|
| 18 |
#include "TestUtil.cc" |
| 19 |
|
| 20 |
const int SC_CONSOLE_MARK = 0xFFF2; |
| 21 |
const int SC_CONSOLE_SELECT_ALL = 0xFFF5; |
| 22 |
|
| 23 |
int main(int argc, char *argv[]) { |
| 24 |
if (argc == 1) { |
| 25 |
startChildProcess(L"CHILD"); |
| 26 |
return 0; |
| 27 |
} |
| 28 |
|
| 29 |
setWindowPos(0, 0, 1, 1); |
| 30 |
setBufferSize(80, 25); |
| 31 |
setWindowPos(0, 0, 80, 25); |
| 32 |
|
| 33 |
countDown(5); |
| 34 |
|
| 35 |
SendMessage(GetConsoleWindow(), WM_SYSCOMMAND, SC_CONSOLE_SELECT_ALL, 0); |
| 36 |
Sleep(2000); |
| 37 |
|
| 38 |
// This API call does not return. In the console window, the "Select All" |
| 39 |
// operation appears to end. The console window becomes non-responsive, |
| 40 |
// and the conhost.exe process must be killed from the Task Manager. |
| 41 |
// (Killing this test program or closing the console window is not |
| 42 |
// sufficient.) |
| 43 |
// |
| 44 |
// The same hang occurs whether line resizing is off or on. It happens |
| 45 |
// with both "Mark" and "Select All". Calling setBufferSize with the |
| 46 |
// existing buffer size does not hang, but calling it with only a changed |
| 47 |
// buffer height *does* hang. Calling setWindowPos does not hang. |
| 48 |
setBufferSize(120, 25); |
| 49 |
|
| 50 |
printf("Done...\n"); |
| 51 |
Sleep(2000); |
| 52 |
} |