From: Heikki Linnakangas Date: Tue, 7 Jul 2026 15:11:28 +0000 (+0300) Subject: pg_dump: check for _beginthreadex() failure in parallel dump X-Git-Tag: REL_19_BETA2~40 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4746a35e45ab360fa3408da0367c4165a5cb8837;p=thirdparty%2Fpostgresql.git 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. Author: Bryan Green Discussion: https://www.postgresql.org/message-id/8c712d76-ecf7-4749-a6d8-dddc01f298ec@gmail.com Backpatch-through: 14 --- diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c index 7e2e9f958ea..abcf0d55277 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 */