From 623aa05ac775c36c7427fca90205d3bd06949775 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 9 Jan 2020 10:32:19 -0500 Subject: [PATCH] win: remove bad assert in uv_loop_close MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This assert was stronger than necessary (we assert the actual condition later in this function). And it's vulnerable to a race condition occurring in uv__work_done where we drain the work queue but still have a stale message on this object. Fixes: https://github.com/libuv/libuv/issues/2610 PR-URL: https://github.com/libuv/libuv/pull/2615 Reviewed-By: Anna Henningsen Reviewed-By: Saúl Ibarra Corretgé Reviewed-By: Colin Ihrig --- src/win/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/win/core.c b/src/win/core.c index e9d0a581..6ded90cd 100644 --- a/src/win/core.c +++ b/src/win/core.c @@ -321,8 +321,13 @@ void uv__loop_close(uv_loop_t* loop) { uv__loops_remove(loop); - /* close the async handle without needing an extra loop iteration */ - assert(!loop->wq_async.async_sent); + /* Close the async handle without needing an extra loop iteration. + * We might have a pending message, but we're just going to destroy the IOCP + * soon, so we can just discard it now without the usual risk of a getting + * another notification from GetQueuedCompletionStatusEx after calling the + * close_cb (which we also skip defining). We'll assert later that queue was + * actually empty and all reqs handled. */ + loop->wq_async.async_sent = 0; loop->wq_async.close_cb = NULL; uv__handle_closing(&loop->wq_async); uv__handle_close(&loop->wq_async);