> Until now we just accepted that WAL insertions can contain > random padding. If we don't want that, we should go around and make sure that > there is no padding (or padding is initialized) for *all* WAL records, > document that as the rule, and remove the relevant valgrind suppressions.
While this would be a nice requirement, I don't think we can enforce it for extensions, only for the core, as C has no capabilities to add a rule for this. But we could enforce it for the core code, what do you think about a script that similarly to headercheck detects WAL record issues automatically? That's also good for detecting the current issues, see attached script and the results I get when executing it on the current master branch. Notes: * It tries to find the related SizeOf macros, and if that exists, accepts trailing padding if it's correctly calculated. But it currently doesn't verify that the SizeOf macro is currently used everywhere (that also seems doable with some greps) * It also has a whitelist for non wal structs in these headers and 2 cases where we explicitly document that padding is ok (not sure if this latter should be really in the whitelist or not)
./src/include/access/heapam_xlog.h:139:33: warning: padding struct to align ‘relids’ [-Wpadded] (struct xl_heap_truncate) ./src/include/access/heapam_xlog.h:184:25: warning: padding struct to align ‘ntuples’ [-Wpadded] (struct xl_heap_multi_insert) ./src/include/access/heapam_xlog.h:376:26: warning: padding struct to align ‘plans’ [-Wpadded] (struct xlhp_freeze_plans) ./src/include/access/heapam_xlog.h:437:33: warning: padding struct to align ‘dbId’ [-Wpadded] (struct xl_heap_inplace) ./src/include/access/heapam_xlog.h:440:33: warning: padding struct to align ‘nmsgs’ [-Wpadded] (struct xl_heap_inplace) ./src/include/access/heapam_xlog.h:486:25: warning: padding struct to align ‘offset’ [-Wpadded] (struct xl_heap_rewrite_mapping) ./src/include/access/heapam_xlog.h:488:25: warning: padding struct to align ‘start_lsn’ [-Wpadded] (struct xl_heap_rewrite_mapping) ./src/include/access/hash_xlog.h:260:22: warning: padding struct to align ‘offsets’ [-Wpadded] (struct xl_hash_vacuum_one_page) ./src/include/access/nbtxlog.h:58:1: warning: padding struct size to alignment boundary with 3 bytes [-Wpadded] (struct xl_btree_metadata, no SizeOf macro) ./src/include/access/nbtxlog.h:288:21: warning: padding struct to align ‘leafblk’ [-Wpadded] (struct xl_btree_mark_page_halfdead) ./src/include/access/nbtxlog.h:315:27: warning: padding struct to align ‘safexid’ [-Wpadded] (struct xl_btree_unlink_page) ./src/include/access/xact.h:368:25: warning: padding struct to align ‘gidlen’ [-Wpadded] (struct xl_xact_prepare) ./src/include/access/xact.h:390:25: warning: padding struct to align ‘xlocators’ [-Wpadded] (struct xl_xact_parsed_commit) ./src/include/access/xact.h:393:29: warning: padding struct to align ‘stats’ [-Wpadded] (struct xl_xact_parsed_commit) ./src/include/access/xact.h:396:36: warning: padding struct to align ‘msgs’ [-Wpadded] (struct xl_xact_parsed_commit) ./src/include/access/xact.h:403:29: warning: padding struct to align ‘abortstats’ [-Wpadded] (struct xl_xact_parsed_commit) ./src/include/access/xact.h:423:25: warning: padding struct to align ‘xlocators’ [-Wpadded] (struct xl_xact_parsed_abort) ./src/include/access/xact.h:426:29: warning: padding struct to align ‘stats’ [-Wpadded] (struct xl_xact_parsed_abort) ./src/include/access/xact.h:431:25: warning: padding struct to align ‘origin_lsn’ [-Wpadded] (struct xl_xact_parsed_abort) ./src/include/access/brin_xlog.h:92:24: warning: padding struct to align ‘insert’ [-Wpadded] (struct xl_brin_update) ./src/include/access/ginxlog.h:61:24: warning: padding struct to align ‘tuple’ [-Wpadded] (struct ginxlogCreatePostingTree) ./src/include/access/ginxlog.h:119:1: warning: padding struct size to alignment boundary with 2 bytes [-Wpadded] (struct ginxlogSplit, no SizeOf macro) ./src/include/access/ginxlog.h:158:21: warning: padding struct to align ‘rightLink’ [-Wpadded] (struct ginxlogDeletePage) ./src/include/access/ginxlog.h:171:25: warning: padding struct to align ‘metadata’ [-Wpadded] (struct ginxlogUpdateMeta) ./src/include/access/ginxlog.h:178:1: warning: padding struct size to alignment boundary with 4 bytes [-Wpadded] (struct ginxlogUpdateMeta, no SizeOf macro) ./src/include/access/ginxlog.h:210:1: warning: padding struct size to alignment boundary with 4 bytes [-Wpadded] (struct ginxlogDeleteListPages, no SizeOf macro) ./src/include/access/spgxlog.h:40:1: warning: padding struct size to alignment boundary with 3 bytes [-Wpadded] (struct spgxlogState, no SizeOf macro) ./src/include/access/spgxlog.h:72:22: warning: padding struct to align ‘offnumParent’ [-Wpadded] (struct spgxlogMoveLeafs) ./src/include/access/spgxlog.h:75:22: warning: padding struct to align ‘stateSrc’ [-Wpadded] (struct spgxlogMoveLeafs) ./src/include/access/spgxlog.h:130:22: warning: padding struct to align ‘stateSrc’ [-Wpadded] (struct spgxlogAddNode) ./src/include/access/spgxlog.h:169:25: warning: padding struct to align ‘nDelete’ [-Wpadded] (struct spgxlogPickSplit) ./src/include/access/spgxlog.h:182:22: warning: padding struct to align ‘offnumParent’ [-Wpadded] (struct spgxlogPickSplit) ./src/include/access/spgxlog.h:185:22: warning: padding struct to align ‘stateSrc’ [-Wpadded] (struct spgxlogPickSplit) ./src/include/access/spgxlog.h:230:22: warning: padding struct to align ‘stateSrc’ [-Wpadded] (struct spgxlogVacuumRoot) ./src/include/access/spgxlog.h:247:22: warning: padding struct to align ‘offsets’ [-Wpadded] (struct spgxlogVacuumRedirect) ./src/include/access/gistxlog.h:58:22: warning: padding struct to align ‘offsets’ [-Wpadded] (struct gistxlogDelete) ./src/include/access/gistxlog.h:71:25: warning: padding struct to align ‘orignsn’ [-Wpadded] (struct gistxlogPageSplit) ./src/include/access/gistxlog.h:74:25: warning: padding struct to align ‘npage’ [-Wpadded] (struct gistxlogPageSplit) ./src/include/access/gistxlog.h:80:1: warning: padding struct size to alignment boundary with 3 bytes [-Wpadded] (struct gistxlogPageSplit, no SizeOf macro) ./src/include/access/multixact.h:75:25: warning: padding struct to align ‘moff’ [-Wpadded] (struct xl_multixact_create) ./src/include/replication/message.h:24:25: warning: padding struct to align ‘prefix_size’ [-Wpadded] (struct xl_logical_message) ./src/include/replication/origin.h:23:1: warning: padding struct size to alignment boundary with 5 bytes [-Wpadded] (struct xl_replorigin_set, no SizeOf macro) ./src/include/storage/standbydefs.h:52:23: warning: padding struct to align ‘nextXid’ [-Wpadded] (struct xl_running_xacts) ./src/include/storage/standbydefs.h:68:33: warning: padding struct to align ‘nmsgs’ [-Wpadded] (struct xl_invalidations)
walstructcheck
Description: Binary data
