From c51522c08f8882b6d4a93b11325f09cd44aea1ba Mon Sep 17 00:00:00 2001 From: sivadeilra Date: Sat, 29 Apr 2023 03:59:56 -0700 Subject: [PATCH] win: fix race condition in uv__init_console() (#3973) Co-authored-by: Arlie Davis Fixes: https://github.com/libuv/libuv/issues/3970 --- src/win/tty.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/win/tty.c b/src/win/tty.c index c41a16ef..60f249b6 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -170,14 +170,14 @@ void uv__console_init(void) { 0); if (uv__tty_console_handle != INVALID_HANDLE_VALUE) { CONSOLE_SCREEN_BUFFER_INFO sb_info; - QueueUserWorkItem(uv__tty_console_resize_message_loop_thread, - NULL, - WT_EXECUTELONGFUNCTION); uv_mutex_init(&uv__tty_console_resize_mutex); if (GetConsoleScreenBufferInfo(uv__tty_console_handle, &sb_info)) { uv__tty_console_width = sb_info.dwSize.X; uv__tty_console_height = sb_info.srWindow.Bottom - sb_info.srWindow.Top + 1; } + QueueUserWorkItem(uv__tty_console_resize_message_loop_thread, + NULL, + WT_EXECUTELONGFUNCTION); } } @@ -2423,7 +2423,6 @@ static void uv__tty_console_signal_resize(void) { height = sb_info.srWindow.Bottom - sb_info.srWindow.Top + 1; uv_mutex_lock(&uv__tty_console_resize_mutex); - assert(uv__tty_console_width != -1 && uv__tty_console_height != -1); if (width != uv__tty_console_width || height != uv__tty_console_height) { uv__tty_console_width = width; uv__tty_console_height = height;