0001-Fix-memory-leak-in-pgstat_progress_parallel_incr_par.patch
application/octet-stream
Filename: 0001-Fix-memory-leak-in-pgstat_progress_parallel_incr_par.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch 0001
Subject: Fix memory leak in pgstat_progress_parallel_incr_param()
| File | + | − |
|---|---|---|
| src/backend/utils/activity/backend_progress.c | 0 | 2 |
From c7972bc8ee34ec111440bf948c0cebe476fd8cdb Mon Sep 17 00:00:00 2001
From: Baji Shaik <baji.pgdev@gmail.com>
Date: Fri, 5 Jun 2026 18:41:47 -0500
Subject: [PATCH 1/2] Fix memory leak in pgstat_progress_parallel_incr_param()
When called from a parallel worker, pgstat_progress_parallel_incr_param()
calls initStringInfo() on a static StringInfoData and then immediately
calls pq_beginmessage(), which calls initStringInfo() again. The second
call overwrites buf->data with a freshly palloc'd buffer, orphaning the
first one. pq_endmessage() then frees only the second buffer, so each
call leaks ~1 kB into the per-worker memory context.
Fix by removing the redundant initStringInfo() call.
Oversight of f1889729dd3 ("Add new parallel message type to progress
reporting").
Author: Baji Shaik <baji.pgdev@gmail.com>
---
src/backend/utils/activity/backend_progress.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/backend/utils/activity/backend_progress.c b/src/backend/utils/activity/backend_progress.c
index b0359771de5..6d2049105ab 100644
--- a/src/backend/utils/activity/backend_progress.c
+++ b/src/backend/utils/activity/backend_progress.c
@@ -100,8 +100,6 @@ pgstat_progress_parallel_incr_param(int index, int64 incr)
{
static StringInfoData progress_message;
- initStringInfo(&progress_message);
-
pq_beginmessage(&progress_message, PqMsg_Progress);
pq_sendint32(&progress_message, index);
pq_sendint64(&progress_message, incr);
--
2.50.1 (Apple Git-155)