pgsql: Fix dangling smgr_owner pointer when a fake relcache entry is fr - Mailing list pgsql-committers

From Heikki Linnakangas
Subject pgsql: Fix dangling smgr_owner pointer when a fake relcache entry is fr
Date
Msg-id E1WLtIc-0000n6-5B@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix dangling smgr_owner pointer when a fake relcache entry is freed.

A fake relcache entry can "own" a SmgrRelation object, like a regular
relcache entry. But when it was free'd, the owner field in SmgrRelation
was not cleared, so it was left pointing to free'd memory.

Amazingly this apparently hasn't caused crashes in practice, or we would've
heard about it earlier. Andres found this with Valgrind.

Report and fix by Andres Freund, with minor modifications by me. Backpatch
to all supported versions.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/0f714c602cd260cace1f8c2d61896d7851990021

Modified Files
--------------
src/backend/access/transam/xlogutils.c |    3 +++
src/backend/storage/smgr/smgr.c        |   18 ++++++++++++++++++
src/include/storage/smgr.h             |    1 +
3 files changed, 22 insertions(+)


pgsql-committers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: pgsql: Fix dangling smgr_owner pointer when a fake relcache entry is fr
Next
From: Heikki Linnakangas
Date:
Subject: pgsql: Avoid memcpy() with same source and destination address.