From 79af3d54ee86523ebb3ed8e2be16cea58ebac6e7 Mon Sep 17 00:00:00 2001 From: David Rowley Date: Thu, 15 Oct 2026 15:59:00 +1300 Subject: [PATCH v1] Adjust weird usages of sentinel_ok() All other callers of sentinel_ok() pass the palloc'd address to the function and the size of the allocation as the 2nd parameter. This adjusts 3 locations that were passing the MemoryChunk and adding on sizeof(MemoryChunk) onto the byte count. Effectively, it's the same byte, but a strange way to calculate it. --- src/backend/utils/mmgr/aset.c | 2 +- src/backend/utils/mmgr/generation.c | 2 +- src/backend/utils/mmgr/slab.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index 6a9ea367107..2fe36c7505b 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -1776,7 +1776,7 @@ AllocSetCheck(MemoryContext context) * Check for overwrite of padding space in an allocated chunk. */ if (dsize != InvalidAllocSize && dsize < chsize && - !sentinel_ok(chunk, ALLOC_CHUNKHDRSZ + dsize)) + !sentinel_ok(MemoryChunkGetPointer(chunk), dsize)) elog(WARNING, "problem in alloc set %s: detected write past chunk end in block %p, chunk %p", name, block, chunk); diff --git a/src/backend/utils/mmgr/generation.c b/src/backend/utils/mmgr/generation.c index 609c9bdc9a6..4be89ee78a1 100644 --- a/src/backend/utils/mmgr/generation.c +++ b/src/backend/utils/mmgr/generation.c @@ -1208,7 +1208,7 @@ GenerationCheck(MemoryContext context) /* check sentinel */ Assert(chunk->requested_size < chunksize); - if (!sentinel_ok(chunk, Generation_CHUNKHDRSZ + chunk->requested_size)) + if (!sentinel_ok(MemoryChunkGetPointer(chunk), chunk->requested_size)) elog(WARNING, "problem in Generation %s: detected write past chunk end in block %p, chunk %p", name, block, chunk); } diff --git a/src/backend/utils/mmgr/slab.c b/src/backend/utils/mmgr/slab.c index 2ad325547fd..b60c8c02841 100644 --- a/src/backend/utils/mmgr/slab.c +++ b/src/backend/utils/mmgr/slab.c @@ -1167,7 +1167,7 @@ SlabCheck(MemoryContext context) /* check the sentinel byte is intact */ Assert(slab->chunkSize < (slab->fullChunkSize - Slab_CHUNKHDRSZ)); - if (!sentinel_ok(chunk, Slab_CHUNKHDRSZ + slab->chunkSize)) + if (!sentinel_ok(MemoryChunkGetPointer(chunk), slab->chunkSize)) elog(WARNING, "problem in slab %s: detected write past chunk end in block %p, chunk %p", name, block, chunk); } -- 2.53.0