Invalid memory access in pg_stat_get_subscription

From: Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Invalid memory access in pg_stat_get_subscription
Date: 2022-06-07 17:06:23
Message-ID: CAGz5QCJykEDzW6jQK6Yz7Qh_PMtD=95de_7QoocbVR2Qy8hWZA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello hackers,

While exploring some code in logical replication worker
implementation, I noticed that we're accessing an invalid memory while
traversing LogicalRepCtx->workers[i].
For the above structure, we're allocating
max_logical_replication_workers times LogicalRepWorker amount of
memory in ApplyLauncherShmemSize. But, in the for loop, we're
accessing the max_logical_replication_workers + 1 location which is
resulting in random crashes.

Please find the patch that fixes the issue. I'm not sure whether we
should add a regression test for the same.

--
Thanks & Regards,
Kuntal Ghosh

Attachment Content-Type Size
0001-Fix-terminating-condition-while-fetching-the-replica.patch application/octet-stream 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2022-06-07 17:47:11 Re: pgcon unconference / impact of block size on performance
Previous Message Tom Lane 2022-06-07 17:02:23 Re: How about a psql backslash command to show GUCs?