From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, Cary Huang <cary(dot)huang(at)highgo(dot)ca>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Avoid memory leaks during base backups |
Date: | 2022-10-20 16:18:30 |
Message-ID: | CA+TgmoaOvrzCqgWWGbb+CJz5Wx05LxdD5gLbQQcOw8aimfeehA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Oct 20, 2022 at 6:47 AM Bharath Rupireddy
<bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
> I tried implementing this, please see the attached v7 patch.
I haven't checked this in detail but it looks much more reasonable in
terms of code footprint. However, we should, I think, set backup_state
= NULL and tablespace_map = NULL before deleting the memory context.
As you have it, I believe that if backup_state = (BackupState *)
palloc0(sizeof(BackupState)) fails -- say due to running out of memory
-- then those variables could end up pointing to garbage because the
context had already been reset before initializing them. I don't know
whether it's possible for that to cause any concrete harm, but nulling
out the pointers seems like cheap insurance.
--
Robert Haas
EDB: http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Mikhail Gribkov | 2022-10-20 16:39:08 | Re: Nicely exiting PG_TRY and PG_CATCH |
Previous Message | Tom Lane | 2022-10-20 16:17:12 | Re: cross-platform pg_basebackup |