diff options
author | Andres Freund <andres@anarazel.de> | 2014-05-07 22:30:05 +0200 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2014-05-24 17:34:22 +0200 |
commit | 0564bbe7a1690f025f4424d5a12cb6af9d428c48 (patch) | |
tree | dee8bdec33bfae9690ea89564d9d2c1d2afdd0dc /src | |
parent | 37828e87aec2eb0c15655d4ad753644be851e59f (diff) | |
download | postgresql-0564bbe7a1690f025f4424d5a12cb6af9d428c48.tar.gz postgresql-0564bbe7a1690f025f4424d5a12cb6af9d428c48.zip |
Silence a couple of spurious valgrind warnings in inval.c.
Define padding bytes in SharedInvalidationMessage structs to be
defined. Otherwise the sinvaladt.c ringbuffer, which is accessed by
multiple processes, will cause spurious valgrind warnings about
undefined memory being used. That's because valgrind remembers the
undefined bytes from the last local process's store, not realizing
that another process has written since, filling the previously
uninitialized bytes.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/cache/inval.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index 59714697c69..a7a768efa61 100644 --- a/src/backend/utils/cache/inval.c +++ b/src/backend/utils/cache/inval.c @@ -103,6 +103,7 @@ #include "storage/smgr.h" #include "utils/catcache.h" #include "utils/inval.h" +#include "utils/memdebug.h" #include "utils/memutils.h" #include "utils/rel.h" #include "utils/relmapper.h" @@ -332,6 +333,17 @@ AddCatcacheInvalidationMessage(InvalidationListHeader *hdr, msg.cc.id = (int8) id; msg.cc.dbId = dbId; msg.cc.hashValue = hashValue; + /* + * Define padding bytes in SharedInvalidationMessage structs to be + * defined. Otherwise the sinvaladt.c ringbuffer, which is accessed by + * multiple processes, will cause spurious valgrind warnings about + * undefined memory being used. That's because valgrind remembers the + * undefined bytes from the last local process's store, not realizing that + * another process has written since, filling the previously uninitialized + * bytes + */ + VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg)); + AddInvalidationMessage(&hdr->cclist, &msg); } @@ -347,6 +359,9 @@ AddCatalogInvalidationMessage(InvalidationListHeader *hdr, msg.cat.id = SHAREDINVALCATALOG_ID; msg.cat.dbId = dbId; msg.cat.catId = catId; + /* check AddCatcacheInvalidationMessage() for an explanation */ + VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg)); + AddInvalidationMessage(&hdr->cclist, &msg); } @@ -370,6 +385,9 @@ AddRelcacheInvalidationMessage(InvalidationListHeader *hdr, msg.rc.id = SHAREDINVALRELCACHE_ID; msg.rc.dbId = dbId; msg.rc.relId = relId; + /* check AddCatcacheInvalidationMessage() for an explanation */ + VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg)); + AddInvalidationMessage(&hdr->rclist, &msg); } @@ -393,6 +411,9 @@ AddSnapshotInvalidationMessage(InvalidationListHeader *hdr, msg.sn.id = SHAREDINVALSNAPSHOT_ID; msg.sn.dbId = dbId; msg.sn.relId = relId; + /* check AddCatcacheInvalidationMessage() for an explanation */ + VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg)); + AddInvalidationMessage(&hdr->rclist, &msg); } @@ -1242,6 +1263,9 @@ CacheInvalidateSmgr(RelFileNodeBackend rnode) msg.sm.backend_hi = rnode.backend >> 16; msg.sm.backend_lo = rnode.backend & 0xffff; msg.sm.rnode = rnode.node; + /* check AddCatcacheInvalidationMessage() for an explanation */ + VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg)); + SendSharedInvalidMessages(&msg, 1); } @@ -1267,6 +1291,9 @@ CacheInvalidateRelmap(Oid databaseId) msg.rm.id = SHAREDINVALRELMAP_ID; msg.rm.dbId = databaseId; + /* check AddCatcacheInvalidationMessage() for an explanation */ + VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg)); + SendSharedInvalidMessages(&msg, 1); } |