Re: Fwd: race in pg_ctl start -w

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Dave Vitek <dvitek(at)grammatech(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Fwd: race in pg_ctl start -w
Date: 2012-10-18 19:36:50
Message-ID: 50805A52.6050009@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 18.10.2012 22:15, Alvaro Herrera wrote:
> Dave Vitek wrote:
>
>> Heikki,
>>
>> It's happy about the overruns. It did flag an issue where the file
>> descriptor can leak when the various early returns get taken.
>
> This is a common problem with static analysers; they don't realise we
> don't care about the leaked resource because the program is shortly
> going to terminate anyway. We (used to?) have plenty of false positives
> in initdb as reported in the Coverity scanner, for example.

Actually, this was a real leak. I should've put close() calls to the
cases where the file is empty, or fstat() fails. It doesn't matter when
the function is called only once, but in the "pg_ctl start -w" case it's
called repeatedly to poll for postmaster startup.

Fixed, and I also changed it to not return the last line if it doesn't
end in a newline, per Tom's suggestion.

- Heikki

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Craig Ringer 2012-10-19 03:44:37 Re: BUG #7613: INTIDB
Previous Message Gezeala M. Bacuño II 2012-10-18 19:18:03 Re: BUG #7521: Cannot disable WAL log while using pg_dump