Re: Memory leak with XLogFileCopy since de768844 (WAL file with .partial)

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: Memory leak with XLogFileCopy since de768844 (WAL file with .partial)
Date: 2015-06-05 13:45:25
Message-ID: CAHGQGwFgMeJj8MH4e-u7KfDXi+4MAahG_YDjxbhbWZDx_Shkkg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jun 5, 2015 at 12:39 PM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
>
>
> On Thu, Jun 4, 2015 at 10:40 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>>
>> On Mon, Jun 1, 2015 at 4:24 PM, Michael Paquier
>> <michael(dot)paquier(at)gmail(dot)com> wrote:
>> > On Thu, May 28, 2015 at 9:09 PM, Michael Paquier
>> > <michael(dot)paquier(at)gmail(dot)com> wrote:
>> >> Since commit de768844, XLogFileCopy of xlog.c returns to caller a
>> >> pstrdup'd string that can be used afterwards for other things.
>> >> XLogFileCopy is used in only one place, and it happens that the result
>> >> string is never freed at all, leaking memory.
>>
>> That seems to be almost harmless because the startup process will exit
>> just after calling XLogFileCopy(). No?
>
>
> Yes that's harmless. My point here is correctness, prevention does not hurt
> particularly if this code path is used more in the future.

Why don't we call InstallXLogFileSegment() at the end of XLogFileCopy()?
If we do that, the risk of memory leak you're worried will disappear at all.

Regards,

--
Fujii Masao

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-06-05 13:46:08 Re: RFC: Remove contrib entirely
Previous Message Simon Riggs 2015-06-05 13:42:45 Re: RFC: Remove contrib entirely