Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0564bbe

Browse files
committed
Silence a couple of spurious valgrind warnings in inval.c.
Define padding bytes in SharedInvalidationMessage structs to bedefined. Otherwise the sinvaladt.c ringbuffer, which is accessed bymultiple processes, will cause spurious valgrind warnings aboutundefined memory being used. That's because valgrind remembers theundefined bytes from the last local process's store, not realizingthat another process has written since, filling the previouslyuninitialized bytes.
1 parent37828e8 commit0564bbe

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎src/backend/utils/cache/inval.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
#include"storage/smgr.h"
104104
#include"utils/catcache.h"
105105
#include"utils/inval.h"
106+
#include"utils/memdebug.h"
106107
#include"utils/memutils.h"
107108
#include"utils/rel.h"
108109
#include"utils/relmapper.h"
@@ -332,6 +333,17 @@ AddCatcacheInvalidationMessage(InvalidationListHeader *hdr,
332333
msg.cc.id= (int8)id;
333334
msg.cc.dbId=dbId;
334335
msg.cc.hashValue=hashValue;
336+
/*
337+
* Define padding bytes in SharedInvalidationMessage structs to be
338+
* defined. Otherwise the sinvaladt.c ringbuffer, which is accessed by
339+
* multiple processes, will cause spurious valgrind warnings about
340+
* undefined memory being used. That's because valgrind remembers the
341+
* undefined bytes from the last local process's store, not realizing that
342+
* another process has written since, filling the previously uninitialized
343+
* bytes
344+
*/
345+
VALGRIND_MAKE_MEM_DEFINED(&msg,sizeof(msg));
346+
335347
AddInvalidationMessage(&hdr->cclist,&msg);
336348
}
337349

@@ -347,6 +359,9 @@ AddCatalogInvalidationMessage(InvalidationListHeader *hdr,
347359
msg.cat.id=SHAREDINVALCATALOG_ID;
348360
msg.cat.dbId=dbId;
349361
msg.cat.catId=catId;
362+
/* check AddCatcacheInvalidationMessage() for an explanation */
363+
VALGRIND_MAKE_MEM_DEFINED(&msg,sizeof(msg));
364+
350365
AddInvalidationMessage(&hdr->cclist,&msg);
351366
}
352367

@@ -370,6 +385,9 @@ AddRelcacheInvalidationMessage(InvalidationListHeader *hdr,
370385
msg.rc.id=SHAREDINVALRELCACHE_ID;
371386
msg.rc.dbId=dbId;
372387
msg.rc.relId=relId;
388+
/* check AddCatcacheInvalidationMessage() for an explanation */
389+
VALGRIND_MAKE_MEM_DEFINED(&msg,sizeof(msg));
390+
373391
AddInvalidationMessage(&hdr->rclist,&msg);
374392
}
375393

@@ -393,6 +411,9 @@ AddSnapshotInvalidationMessage(InvalidationListHeader *hdr,
393411
msg.sn.id=SHAREDINVALSNAPSHOT_ID;
394412
msg.sn.dbId=dbId;
395413
msg.sn.relId=relId;
414+
/* check AddCatcacheInvalidationMessage() for an explanation */
415+
VALGRIND_MAKE_MEM_DEFINED(&msg,sizeof(msg));
416+
396417
AddInvalidationMessage(&hdr->rclist,&msg);
397418
}
398419

@@ -1242,6 +1263,9 @@ CacheInvalidateSmgr(RelFileNodeBackend rnode)
12421263
msg.sm.backend_hi=rnode.backend >>16;
12431264
msg.sm.backend_lo=rnode.backend&0xffff;
12441265
msg.sm.rnode=rnode.node;
1266+
/* check AddCatcacheInvalidationMessage() for an explanation */
1267+
VALGRIND_MAKE_MEM_DEFINED(&msg,sizeof(msg));
1268+
12451269
SendSharedInvalidMessages(&msg,1);
12461270
}
12471271

@@ -1267,6 +1291,9 @@ CacheInvalidateRelmap(Oid databaseId)
12671291

12681292
msg.rm.id=SHAREDINVALRELMAP_ID;
12691293
msg.rm.dbId=databaseId;
1294+
/* check AddCatcacheInvalidationMessage() for an explanation */
1295+
VALGRIND_MAKE_MEM_DEFINED(&msg,sizeof(msg));
1296+
12701297
SendSharedInvalidMessages(&msg,1);
12711298
}
12721299

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp