From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix memory lifetime issues of replication slot stats.
Date: Wed, 17 Mar 2021 23:24:57 +0000
Message-ID: <E1lMfX7-0000f3-Tr@gemulon.postgresql.org> (raw)
Fix memory lifetime issues of replication slot stats.
When accessing replication slot stats, introduced in 98681675002d,
pgstat_read_statsfiles() reads the data into newly allocated
memory. Unfortunately the current memory context at that point is the
callers, leading to leaks and use-after-free dangers.
The fix is trivial, explicitly use pgStatLocalContext. There's some
potential for further improvements, but that's outside of the scope of
this bugfix.
No backpatch necessary, feature is only in HEAD.
Author: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/20210317230447.c7uc4g3vbs4wi32i@alap3.anarazel.de
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/5f79580ad69f6e696365bdc63bc265f45bd77211
Modified Files
--------------
contrib/test_decoding/expected/stats.out | 16 ++++++++++++++++
contrib/test_decoding/sql/stats.sql | 7 +++++++
src/backend/postmaster/pgstat.c | 6 +++++-
3 files changed, 28 insertions(+), 1 deletion(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: andres@anarazel.de
Subject: Re: pgsql: Fix memory lifetime issues of replication slot stats.
In-Reply-To: <E1lMfX7-0000f3-Tr@gemulon.postgresql.org>
References: <E1lMfX7-0000f3-Tr@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox