Re: Xact end leaves CurrentMemoryContext = TopMemoryContext

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Xact end leaves CurrentMemoryContext = TopMemoryContext
Дата
Msg-id 20240617214305.xb6cl6olizb6ij6i@awork3.anarazel.de
обсуждение исходный текст
Ответ на Xact end leaves CurrentMemoryContext = TopMemoryContext  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

On 2024-06-17 16:37:05 -0400, Tom Lane wrote:
> As to what to do about it: I'm imagining that instead of resetting
> CurrentMemoryContext to TopMemoryContext, we set it to some special
> context that we expect we can reset every so often, like at the start
> of the next transaction.  The existing TransactionAbortContext is
> a very similar thing, and maybe could be repurposed/shared with this
> usage.

One issue is that that could lead to hard to find use-after-free issues in
currently working code. Right now allocations made "between transactions"
live forever, if we just use a different context it won't anymore.

Particularly if the reset is only occasional, we'd make it hard to find
buggy allocations.

I wonder if we ought to set CurrentMemoryContext to NULL in that timeframe,
forcing code to explicitly choose what lifetime is needed, rather than just
defaulting such code into changed semantics.

Greetings,

Andres Freund



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

Предыдущее
От: Justin Pryzby
Дата:
Сообщение: Re: Reducing the log spam
Следующее
От: Greg Sabino Mullane
Дата:
Сообщение: Re: cost delay brainstorming