Skip to content

Commit

Permalink
win,tty: fix deadlock caused by inconsistent state
Browse files Browse the repository at this point in the history
The variable uv__read_console_status is left as IN_PROGRESS when the
operation was cancelled by the main thread requesting a trap
(race condition?).

This confuses the next call to uv__cancel_read_console(...) therefore
causing a deadlock due to a semaphore aquisition on the main thread that
is never released by the reading thread.

Fixes: nodejs/node#32999
  • Loading branch information
david-landeros committed Jun 11, 2020
1 parent 2967557 commit e6602ed
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/win/tty.c
Expand Up @@ -517,6 +517,7 @@ static DWORD CALLBACK uv_tty_line_read_thread(void* data) {
status = InterlockedExchange(&uv__read_console_status, IN_PROGRESS);
if (status == TRAP_REQUESTED) {
SET_REQ_SUCCESS(req);
InterlockedExchange(&uv__read_console_status, COMPLETED);
req->u.io.overlapped.InternalHigh = 0;
POST_COMPLETION_FOR_REQ(loop, req);
return 0;
Expand Down

0 comments on commit e6602ed

Please sign in to comment.