Re: Reducing the chunk header sizes on all memory context types

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Reducing the chunk header sizes on all memory context types
Дата
Msg-id 20221006190058.rgk4gxa34d6rg77o@awork3.anarazel.de
обсуждение исходный текст
Ответ на Re: Reducing the chunk header sizes on all memory context types  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Reducing the chunk header sizes on all memory context types
Список pgsql-hackers
Hi,

On 2022-10-06 14:19:21 -0400, Tom Lane wrote:
> One more thing: based on what I saw in working with my pending guc.c
> changes, the assertions in GetMemoryChunkMethodID are largely useless
> for detecting bogus pointers.  I think we should do something more
> like the attached, which will result in a clean failure if the method
> ID bits are invalid.

Yea, that makes sense. I wouldn't get rid of the MAXALIGN Assert though - it's
not replaced by the the unused mcxt stuff afaics.


> I'm a little tempted also to rearrange the MemoryContextMethodID enum
> so that likely bit patterns like 000 are not valid IDs.

Yea, I was suggesting that during a review as well. We can still relax it
later if we run out of bits.


> +/*
> + * Support routines to trap use of invalid memory context method IDs
> + * (from calling pfree or the like on a bogus pointer).
> + */
> +static void
> +BogusFree(void *pointer)
> +{
> +    elog(ERROR, "pfree called with invalid pointer %p", pointer);
> +}

Maybe worth printing the method ID as well?

Greetings,

Andres Freund



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: list of acknowledgments for PG15
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Reducing the chunk header sizes on all memory context types