pgsql: Prevent memory leaks in RelationGetIndexList, RelationGetIndexAt - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Prevent memory leaks in RelationGetIndexList, RelationGetIndexAt
Date
Msg-id E1XHaao-0003IY-2s@gemulon.postgresql.org
Whole thread Raw
List 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(+)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Prevent memory leaks in parseRelOptions().
Next
From: Peter Eisentraut
Date:
Subject: pgsql: doc: Remove obsolete set element DSSSL customizations