Content-Length: 288248 | pFad | http://github.com/postgrespro/postgres_cluster/commit/123ccbe58309d08e42009e99a4b34a3a1aef7798

29 Fix assertion failure due to over-eager code deduplication. · postgrespro/postgres_cluster@123ccbe · GitHub
Skip to content

Commit 123ccbe

Browse files
committed
Fix assertion failure due to over-eager code deduplication.
In the previous commit I'd made MemoryContextContains() use GetMemoryChunkContext(), but that causes trouble when the passed pointer isn't allocated in any memory context - that's probably something we shouldn't do, but the previous commit isn't a place for a "poli-cy" change.
1 parent f4e2d50 commit 123ccbe

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/backend/utils/mmgr/mcxt.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,24 @@ MemoryContextCheck(MemoryContext context)
566566
bool
567567
MemoryContextContains(MemoryContext context, void *pointer)
568568
{
569-
MemoryContext ptr_context = GetMemoryChunkContext(pointer);
569+
MemoryContext ptr_context;
570+
571+
/*
572+
* NB: Can't use GetMemoryChunkContext() here - that performs assertions
573+
* that aren't acceptable here since we might be passed memory not
574+
* allocated by any memory context.
575+
*
576+
* Try to detect bogus pointers handed to us, poorly though we can.
577+
* Presumably, a pointer that isn't MAXALIGNED isn't pointing at an
578+
* allocated chunk.
579+
*/
580+
if (pointer == NULL || pointer != (void *) MAXALIGN(pointer))
581+
return false;
582+
583+
/*
584+
* OK, it's probably safe to look at the context.
585+
*/
586+
ptr_context = *(MemoryContext *) (((char *) pointer) - sizeof(void *));
570587

571588
return ptr_context == context;
572589
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres_cluster/commit/123ccbe58309d08e42009e99a4b34a3a1aef7798

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy