Subject: Re: [BUG #17888] Incorrect memory access in gist__int_ops for an input array with many elements

From: David Rowley <[email-masked]>
Date: Wed, 12 Apr 2023 23:48:08 +1200

On Wed, 12 Apr 2023 at 03:49, Ankit Kumar Pandey <[email-masked]> wrote:
> Also, comments on BogusFree mentions `As a possible
> aid in debugging, we report the header word along with the pointer
> address`. How can we interpret useful debugging information from this?
>
> `pfree called with invalid pointer 0x7ff1706d0030 (header
> 0x4fc8000100000000)`

elog(ERROR)s are not meant to happen.  ISTM, what's there is about the
best that can be done with our current infrastructure. If that occurs
on some machine that we can't get access to debug on, then having the
header bits might be useful, at least, certainly much more useful than
just not having them at all.

If you can think of something more useful to put in the elog, then we
could consider changing it to improve it.

Just in case you suggest it, I don't believe it's wise to try and
split it out into the components of MemoryChunk's hdrmask.
MemoryContexts aren't forced into using that. They're only forced into
using the 3 least significant bits for the MemoryContextMethodID.

David