fixup! win: use PROC_THREAD_ATTRIBUTE_HANDLE_LIST in uv_spawn

This commit is contained in:
Jameson Nash 2026-03-26 16:45:54 -04:00
parent 0d4acd733b
commit afb8fd2bdd
3 changed files with 10 additions and 23 deletions

View File

@ -1047,7 +1047,10 @@ int uv_spawn(uv_loop_t* loop,
* inherited, closing the race condition where concurrent uv_spawn calls
* could cause handles intended for one child to leak into another. */
{
int count = uv__stdio_size(child_stdio_buffer);
#define CHILD_STDIO_COUNT(buffer) \
*((unsigned int*) (buffer))
int count = CHILD_STDIO_COUNT(child_stdio_buffer);
#undef CHILD_STDIO_COUNT
int n = 0;
SIZE_T attr_size = 0;

View File

@ -211,25 +211,18 @@ static int maybe_run_test(int argc, char **argv) {
if (strcmp(argv[1], "spawn_helper8") == 0) {
uv_os_fd_t closed_fd;
uv_os_fd_t open_fd;
#ifdef _WIN32
DWORD flags;
HMODULE kernelbase_module;
union {
FARPROC proc;
sCompareObjectHandles pCompareObjectHandles; /* Windows >= 10 */
} u;
#endif
notify_parent_process();
ASSERT_EQ(sizeof(closed_fd), read(0, &closed_fd, sizeof(closed_fd)));
ASSERT_EQ(sizeof(open_fd), read(0, &open_fd, sizeof(open_fd)));
#ifdef _WIN32
DWORD flags;
ASSERT_GT((intptr_t) closed_fd, 0);
ASSERT_GT((intptr_t) open_fd, 0);
ASSERT_NE(0, GetHandleInformation(open_fd, &flags));
kernelbase_module = GetModuleHandleW(L"kernelbase.dll");
u.proc = GetProcAddress(kernelbase_module, "CompareObjectHandles");
if (u.pCompareObjectHandles != NULL)
ASSERT_EQ(FALSE, u.pCompareObjectHandles(open_fd, closed_fd));
ASSERT_EQ(0, GetHandleInformation(open_fd, &flags));
ASSERT_EQ(ERROR_INVALID_HANDLE, GetLastError());
SetLastError(ERROR_SUCCESS);
ASSERT_EQ(0, GetHandleInformation(closed_fd, &flags));
ASSERT_EQ(ERROR_INVALID_HANDLE, GetLastError());
#else
ASSERT_GT(open_fd, 2);
ASSERT_GT(closed_fd, 2);

View File

@ -1677,11 +1677,6 @@ TEST_IMPL(spawn_fs_open) {
uv_stdio_container_t stdio[1];
#ifdef _WIN32
const char dev_null[] = "NUL";
HMODULE kernelbase_module;
union {
FARPROC proc;
sCompareObjectHandles pCompareObjectHandles; /* Windows >= 10 */
} u;
#else
const char dev_null[] = "/dev/null";
#endif
@ -1704,10 +1699,6 @@ TEST_IMPL(spawn_fs_open) {
#ifdef _WIN32
ASSERT_NE(0, DuplicateHandle(GetCurrentProcess(), fd, GetCurrentProcess(), &dup_fd,
0, /* inherit */ TRUE, DUPLICATE_SAME_ACCESS));
kernelbase_module = GetModuleHandleW(L"kernelbase.dll");
u.proc = GetProcAddress(kernelbase_module, "CompareObjectHandles");
if (u.pCompareObjectHandles != NULL)
ASSERT_EQ(TRUE, u.pCompareObjectHandles(fd, dup_fd));
#else
dup_fd = dup(fd);
#endif