diff options
author | David Rowley | 2024-04-07 23:06:31 +0000 |
---|---|---|
committer | David Rowley | 2024-04-07 23:06:31 +0000 |
commit | 705ec0565371033082e7b1c278afcb42aa5a7421 (patch) | |
tree | 5be068a9d07b2df403ae138e32e2123b5340ca92 /src/backend/utils/mmgr/bump.c | |
parent | beabea6c2063e583628c59d03102dba996975b4a (diff) |
Fix incorrect KeeperBlock macro in bump.c
The macro was missing a MAXALIGN around the sizeof(BumpContext) which
would cause problems detecting the keeper block on 32-bit systems that
have a MAXALIGN value of 8.
Thank you to Andres Freund, Tomas Vondra and Tom Lane for investigating
and testing.
Reported-by: Melanie Plageman, Tomas Vondra
Discussion: https://postgr.es/m/CAAKRu_Y6dZjiJEZghgNZp0Gjar1JVq-CH7XGDqExDVHnPgDjuw@mail.gmail.com
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/utils/mmgr/bump.c')
-rw-r--r-- | src/backend/utils/mmgr/bump.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/utils/mmgr/bump.c b/src/backend/utils/mmgr/bump.c index a17d186c742..38e81599262 100644 --- a/src/backend/utils/mmgr/bump.c +++ b/src/backend/utils/mmgr/bump.c @@ -57,7 +57,8 @@ #define Bump_CHUNK_FRACTION 8 /* The keeper block is allocated in the same allocation as the set */ -#define KeeperBlock(set) ((BumpBlock *) ((char *) (set) + sizeof(BumpContext))) +#define KeeperBlock(set) ((BumpBlock *) ((char *) (set) + \ + MAXALIGN(sizeof(BumpContext)))) #define IsKeeperBlock(set, blk) (KeeperBlock(set) == (blk)) typedef struct BumpBlock BumpBlock; /* forward reference */ @@ -198,7 +199,7 @@ BumpContextCreate(MemoryContext parent, const char *name, Size minContextSize, dlist_init(&set->blocks); /* Fill in the initial block's block header */ - block = (BumpBlock *) (((char *) set) + MAXALIGN(sizeof(BumpContext))); + block = KeeperBlock(set); /* determine the block size and initialize it */ firstBlockSize = allocSize - MAXALIGN(sizeof(BumpContext)); BumpBlockInit(set, block, firstBlockSize); |