Re: Avoid memory leaks during base backups - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Avoid memory leaks during base backups
Date
Msg-id CA+TgmoY-b78iBQqLS56aRE-CQyjrFBuV+hT43WcuiuH8Jj_yYQ@mail.gmail.com
Whole thread Raw
In response to Re: Avoid memory leaks during base backups  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Responses Re: Avoid memory leaks during base backups
List pgsql-hackers
On Fri, Oct 21, 2022 at 2:18 AM Michael Paquier <michael@paquier.xyz> wrote:
> AFAIK, one of the callbacks associated to a memory context could
> fail, see comments before MemoryContextCallResetCallbacks() in
> MemoryContextDelete().  I agree that it should not matter here, but I
> think that it is better to reset the pointers before attempting the
> deletion of the memory context in this case.

I think this is nitpicking. There's no real danger here, and if there
were, the error handling would have to take it into account somehow,
which it doesn't.

I'd probably do it before resetting the context as a matter of style,
to make it clear that there's no window in which the pointers are set
but referencing invalid memory. But I do not think it makes any
practical difference at all.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Japin Li
Date:
Subject: Re: parse partition strategy string in gram.y
Next
From: Marina Polyakova
Date:
Subject: Re: ICU for global collation