Skip to content

Commit 1a8336e

Browse files
Ben HillisCopilot
andcommitted
Use overlapped pipes in WSLC session terminate tests
The LoadImage and ImportImage 'session terminate' sub-tests used CreatePipe which creates synchronous pipe handles. When the relay calls ReadFile with an OVERLAPPED structure on a synchronous handle, the call blocks the thread instead of returning ERROR_IO_PENDING. This prevents WaitForMultipleObjects from ever checking the session terminating event, causing a deadlock when Terminate() is called. Replace CreatePipe with OpenAnonymousPipe (FILE_FLAG_OVERLAPPED) so ReadFile returns ERROR_IO_PENDING and the relay's event loop can detect the termination signal. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 94792a4 commit 1a8336e

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

test/windows/WSLCTests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,10 +1095,11 @@ class WSLCTests
10951095
}
10961096

10971097
// Validate that LoadImage is aborted when the session terminates.
1098+
// N.B. The read pipe must support overlapped IO so the relay's event-based cancellation works.
1099+
// CreatePipe creates synchronous pipes where ReadFile blocks the thread, preventing
1100+
// WaitForMultipleObjects from detecting the session terminating event.
10981101
{
1099-
wil::unique_handle pipeRead;
1100-
wil::unique_handle pipeWrite;
1101-
VERIFY_WIN32_BOOL_SUCCEEDED(CreatePipe(&pipeRead, &pipeWrite, nullptr, 2));
1102+
auto [pipeRead, pipeWrite] = wsl::windows::common::wslutil::OpenAnonymousPipe(2, true, false);
11021103

11031104
std::promise<HRESULT> terminateResult;
11041105
wil::unique_event testCompleted{wil::EventOptions::ManualReset};
@@ -1198,10 +1199,9 @@ class WSLCTests
11981199
}
11991200

12001201
// Validate that ImportImage is aborted when the session terminates.
1202+
// N.B. See the equivalent LoadImage test for why overlapped pipes are required here.
12011203
{
1202-
wil::unique_handle pipeRead;
1203-
wil::unique_handle pipeWrite;
1204-
VERIFY_WIN32_BOOL_SUCCEEDED(CreatePipe(&pipeRead, &pipeWrite, nullptr, 2));
1204+
auto [pipeRead, pipeWrite] = wsl::windows::common::wslutil::OpenAnonymousPipe(2, true, false);
12051205

12061206
std::promise<HRESULT> terminateResult;
12071207
wil::unique_event testCompleted{wil::EventOptions::ManualReset};

0 commit comments

Comments
 (0)