David Rowley <dgrowleyml@gmail.com> writes:
> I think the fix is harder than I thought, or perhaps impossible to do
> given how we now determine the owning MemoryContext of a pointer.
> There's a comment in MemoryContextContains which says:
> * NB: Can't use GetMemoryChunkContext() here - that performs assertions
> * that aren't acceptable here since we might be passed memory not
> * allocated by any memory context.
I think MemoryContextContains' charter is to return
GetMemoryChunkContext(pointer) == context
*except* that instead of asserting what GetMemoryChunkContext asserts,
it should treat those cases as reasons to return false. So if you
can still do GetMemoryChunkContext then you can still do
MemoryContextContains. The point of having the separate function
is to be as forgiving as we can of bogus pointers.
regards, tom lane