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

Commitb76fb6c

Browse files
committed
Temporarily make MemoryContextContains return false
5265e91 changed MemoryContextContains to update it so that it workscorrectly with the new MemoryChunk code added inc6e0fe1. However,5265e91 was done with the assumption that MemoryContextContains wouldonly ever be given pointers to memory that had been returned by one of ourMemoryContext allocators. It seems that's not true and many of our 32-bitbuildfarm animals are clearly showing that.There are some code paths that call MemoryContextContains with a pointerpointing part way into an allocated chunk. The example of this found bythe 32-bit buildfarm animals is the int2int4_sum() function. Thisfunction returns transdata->sum, which is not a pointer to memory that wasallocated directly. This return value is then subsequently passed toMemoryContextContains which causes it to crash due to it thinking thememory directly prior to that pointer is a MemoryChunk. What's actuallyin that memory is the field in the struct that comes prior to the "sum"field. This problem didn't occur in 64-bit world because BIGINT is abyval type and the code which was calling MemoryContextContains with thebad pointer only does so with non-byval types.Here, instead of reverting5265e91 and making MemoryContextContainscompletely broken again, let's just make it always return false for now.Effectively prior to5265e91 it was doing that anyway, this at leastmakes that more explicit. The only repercussions of this with the currentMemoryContextContains calls are that we perform a datumCopy() when wemight not need to. This should make the 32-bit buildfarm animals happyagain and give us more time to consider a long-term fix.Discussion:https://postgr.es/m/20220907130552.sfjri7jublfxyyi4%40jrouhaud
1 parente7936f8 commitb76fb6c

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

‎src/backend/utils/mmgr/mcxt.c

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,14 @@ MemoryContextCheck(MemoryContext context)
826826
bool
827827
MemoryContextContains(MemoryContextcontext,void*pointer)
828828
{
829+
/*
830+
* Temporarily make this always return false as we don't yet have a fully
831+
* baked idea on how to make it work correctly with the new MemoryChunk
832+
* code.
833+
*/
834+
return false;
835+
836+
#ifdefNOT_USED
829837
MemoryContextptr_context;
830838

831839
/*
@@ -845,6 +853,7 @@ MemoryContextContains(MemoryContext context, void *pointer)
845853
ptr_context=GetMemoryChunkContext(pointer);
846854

847855
returnptr_context==context;
856+
#endif
848857
}
849858

850859
/*
@@ -960,8 +969,6 @@ MemoryContextAlloc(MemoryContext context, Size size)
960969

961970
VALGRIND_MEMPOOL_ALLOC(context,ret,size);
962971

963-
Assert(MemoryContextContains(context,ret));
964-
965972
returnret;
966973
}
967974

@@ -1000,8 +1007,6 @@ MemoryContextAllocZero(MemoryContext context, Size size)
10001007

10011008
MemSetAligned(ret,0,size);
10021009

1003-
Assert(MemoryContextContains(context,ret));
1004-
10051010
returnret;
10061011
}
10071012

@@ -1040,8 +1045,6 @@ MemoryContextAllocZeroAligned(MemoryContext context, Size size)
10401045

10411046
MemSetLoop(ret,0,size);
10421047

1043-
Assert(MemoryContextContains(context,ret));
1044-
10451048
returnret;
10461049
}
10471050

@@ -1083,8 +1086,6 @@ MemoryContextAllocExtended(MemoryContext context, Size size, int flags)
10831086
if ((flags&MCXT_ALLOC_ZERO)!=0)
10841087
MemSetAligned(ret,0,size);
10851088

1086-
Assert(MemoryContextContains(context,ret));
1087-
10881089
returnret;
10891090
}
10901091

@@ -1168,8 +1169,6 @@ palloc(Size size)
11681169

11691170
VALGRIND_MEMPOOL_ALLOC(context,ret,size);
11701171

1171-
Assert(MemoryContextContains(context,ret));
1172-
11731172
returnret;
11741173
}
11751174

@@ -1203,8 +1202,6 @@ palloc0(Size size)
12031202

12041203
MemSetAligned(ret,0,size);
12051204

1206-
Assert(MemoryContextContains(context,ret));
1207-
12081205
returnret;
12091206
}
12101207

@@ -1244,8 +1241,6 @@ palloc_extended(Size size, int flags)
12441241
if ((flags&MCXT_ALLOC_ZERO)!=0)
12451242
MemSetAligned(ret,0,size);
12461243

1247-
Assert(MemoryContextContains(context,ret));
1248-
12491244
returnret;
12501245
}
12511246

@@ -1299,8 +1294,6 @@ repalloc(void *pointer, Size size)
12991294

13001295
VALGRIND_MEMPOOL_CHANGE(context,pointer,ret,size);
13011296

1302-
Assert(MemoryContextContains(context,ret));
1303-
13041297
returnret;
13051298
}
13061299

@@ -1336,8 +1329,6 @@ MemoryContextAllocHuge(MemoryContext context, Size size)
13361329

13371330
VALGRIND_MEMPOOL_ALLOC(context,ret,size);
13381331

1339-
Assert(MemoryContextContains(context,ret));
1340-
13411332
returnret;
13421333
}
13431334

@@ -1377,8 +1368,6 @@ repalloc_huge(void *pointer, Size size)
13771368

13781369
VALGRIND_MEMPOOL_CHANGE(context,pointer,ret,size);
13791370

1380-
Assert(MemoryContextContains(context,ret));
1381-
13821371
returnret;
13831372
}
13841373

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp