pgsql: Prevent memory leaks in RelationGetIndexList, RelationGetIndexAt

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Prevent memory leaks in RelationGetIndexList, RelationGetIndexAt
Date: 2014-08-13 15:36:02
Message-ID: E1XHaao-0003IY-2s@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Prevent memory leaks in RelationGetIndexList, RelationGetIndexAttrBitmap.

When replacing rd_indexlist, rd_indexattr, etc, we neglected to pfree any
old value of these fields. Under ordinary circumstances, the old value
would always be NULL, so this seemed reasonable enough. However, in cases
where we're rebuilding a system catalog's relcache entry and another cache
flush occurs on that same catalog meanwhile, it's possible for the field to
not be NULL when we return to the outer level, because we already refilled
it while recovering from the inner flush. This leads to a fairly small
session-lifespan leak in CacheMemoryContext. In real-world usage the leak
would be too small to notice; but in testing with CLOBBER_CACHE_RECURSIVELY
the leakage can add up to the point of causing OOM failures, as reported by
Tomas Vondra.

The issue has been there a long time, but it only seems worth fixing in
HEAD, like the previous fix in this area (commit 078b2ed291c758e7).

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/ab8c84db2f7af008151b848cf1d6a4672a39eecd

Modified Files
--------------
src/backend/utils/cache/relcache.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2014-08-14 02:11:22 pgsql: doc: Remove obsolete set element DSSSL customizations
Previous Message Fujii Masao 2014-08-13 02:04:10 pgsql: Expose -S option in pg_receivexlog.