On Mon, 14 Nov 2022 at 15:25, John Naylor <john.nay...@enterprisedb.com> wrote: > - Assert((char *) chunk > (char *) block); > + Assert((char *) chunk >= (char *) block); > > Is this related or independent?
It's related. Because the code is doing: MemoryChunkSetHdrMask(alignedchunk, unaligned, alignto, MCTX_ALIGNED_REDIRECT_ID); Here the blockoffset gets set to the difference between alignedchunk and unaligned. Typically when we call MemoryChunkSetHdrMask, the blockoffset is always the difference between the block and MemoryChunk, which is never 0 due to the block header fields. Here it can be the same pointer when the redirection MemoryChunk is stored on the first byte of the palloc'd address. This can happen if the address returned by palloc + sizeof(MemoryChunk) is aligned to what we need already. David