From 9b4696bb7f24b2ef22e204aa3617c9ad81137476 Mon Sep 17 00:00:00 2001 From: Bryan Green Date: Sun, 28 Jun 2026 10:54:54 -0500 Subject: [PATCH v1 1/4] pg_dump: check for _beginthreadex() failure in parallel dump ParallelBackupStart() stored _beginthreadex()'s return value as the worker's thread handle without checking it. On failure that value is 0, which would later reach WaitForMultipleObjects() as a null handle, caught only by an Assert. The fork() path already calls pg_fatal() when it fails; do the same for _beginthreadex(), as pgbench does. --- src/bin/pg_dump/parallel.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c index 3e84b881ca..b77d2650df 100644 --- a/src/bin/pg_dump/parallel.c +++ b/src/bin/pg_dump/parallel.c @@ -976,6 +976,8 @@ ParallelBackupStart(ArchiveHandle *AH) handle = _beginthreadex(NULL, 0, (void *) &init_spawned_worker_win32, wi, 0, &(slot->threadId)); + if (handle == 0) + pg_fatal("could not create worker thread: %m"); slot->hThread = handle; slot->workerStatus = WRKR_IDLE; #else /* !WIN32 */ -- 2.54.0.windows.1