Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit123ccbe

Browse files
committed
Fix assertion failure due to over-eager code deduplication.
In the previous commit I'd made MemoryContextContains() useGetMemoryChunkContext(), but that causes trouble when the passedpointer isn't allocated in any memory context - that's probablysomething we shouldn't do, but the previous commit isn't a place for a"policy" change.
1 parentf4e2d50 commit123ccbe

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(MemoryContextcontext,void*pointer)
568568
{
569-
MemoryContextptr_context=GetMemoryChunkContext(pointer);
569+
MemoryContextptr_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
returnptr_context==context;
572589
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp