Skip to content

Commit f8969e0

Browse files
committed
Fix asar-exe-test deadlock because write pipe is full
Previously the created pipe had a size of 4096, this lead to a deadlock on the xkasemu.asm test because it output 4400~ bytes of output, which, since not read from the other side, caused the pipe to become full and stop accepting input, blocking everything. This patch fixes it by simply using pageSize * 4 as a size, which is 4096 * 4 bytes. If a test surpasses 4096 * 4 bytes of output, it'll lock up again, for now this is not the case, however in the future a "better" fix would be to read from the pipe continously instead of at the end, as to not let it get full.
1 parent 6275af4 commit f8969e0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/asar-tests/test.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,10 @@ static bool execute_command_line(char * commandline, const char * stdout_log_fil
261261
sa.bInheritHandle = TRUE;
262262
sa.lpSecurityDescriptor = nullptr;
263263

264-
if (!CreatePipe(&stdout_read_handle, &stdout_write_handle, &sa, 0))
264+
SYSTEM_INFO sInfo{};
265+
GetSystemInfo(&sInfo);
266+
267+
if (!CreatePipe(&stdout_read_handle, &stdout_write_handle, &sa, sInfo.dwPageSize * 4))
265268
{
266269
return false;
267270
}
@@ -273,7 +276,7 @@ static bool execute_command_line(char * commandline, const char * stdout_log_fil
273276
return false;
274277
}
275278

276-
if (!CreatePipe(&stderr_read_handle, &stderr_write_handle, &sa, 0))
279+
if (!CreatePipe(&stderr_read_handle, &stderr_write_handle, &sa, sInfo.dwPageSize * 4))
277280
{
278281
CloseHandle(stdout_read_handle);
279282
CloseHandle(stdout_write_handle);

0 commit comments

Comments
 (0)