Skip to content

Commit 705ec05

Browse files
committed
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/a4a10b89-6ba8-4abd-b449-019aafff04fc@enterprisedb.com
1 parent beabea6 commit 705ec05

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/backend/utils/mmgr/bump.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
#define Bump_CHUNK_FRACTION 8
5858

5959
/* The keeper block is allocated in the same allocation as the set */
60-
#define KeeperBlock(set) ((BumpBlock *) ((char *) (set) + sizeof(BumpContext)))
60+
#define KeeperBlock(set) ((BumpBlock *) ((char *) (set) + \
61+
MAXALIGN(sizeof(BumpContext))))
6162
#define IsKeeperBlock(set, blk) (KeeperBlock(set) == (blk))
6263

6364
typedef struct BumpBlock BumpBlock; /* forward reference */
@@ -198,7 +199,7 @@ BumpContextCreate(MemoryContext parent, const char *name, Size minContextSize,
198199
dlist_init(&set->blocks);
199200

200201
/* Fill in the initial block's block header */
201-
block = (BumpBlock *) (((char *) set) + MAXALIGN(sizeof(BumpContext)));
202+
block = KeeperBlock(set);
202203
/* determine the block size and initialize it */
203204
firstBlockSize = allocSize - MAXALIGN(sizeof(BumpContext));
204205
BumpBlockInit(set, block, firstBlockSize);

0 commit comments

Comments
 (0)