pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Vitek <dvitek@grammatech.com>
To: Heikki Linnakangas <hlinnakangas@vmware.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Subject: Re: Fwd: race in pg_ctl start -w
Date: Thu, 18 Oct 2012 15:05:26 -0400
Message-ID: <508052F6.20803@grammatech.com> (raw)
In-Reply-To: <507BC402.40807@vmware.com>
References: <5076F626.2090404@grammatech.com>
	<5076FF23.6020704@iki.fi>
	<22107.1349976592@sss.pgh.pa.us>
	<50771713.8000908@vmware.com>
	<25454.1349984162@sss.pgh.pa.us>
	<507BC402.40807@vmware.com>

On 10/15/2012 4:06 AM, Heikki Linnakangas wrote:
> On 11.10.2012 22:36, Tom Lane wrote:
>> Heikki Linnakangas<hlinnakangas@vmware.com>  writes:
>>> Hmm, starting with 9.3, postmaster can not only create and append to 
>>> the
>>> end of file, it can also inject a line in the middle, shifting the
>>> following lines forwards. In theory, if a new line is injected into the
>>> middle of the file between fgets() calls, readfile() could read part of
>>> the same line twice. Not sure what consequences that could have; pg_ctl
>>> might try to connect to wrong address or socket directory.
>>
>> Hm.  IIRC, the postmaster is careful to write the whole thing in a
>> single write() call, which in principle is atomic.  Perhaps you're
>> right that we'd better have pg_ctl read it in a single read() to
>> ensure that it sees a consistent file state.  Otherwise we're making
>> assumptions about what sort of buffering underlies the stdio functions.
>
> Ok, changed it to slurp the whole file to memory with one read() call.
>
> Dave, did this silence the static analysis tool you used?
>
> - Heikki
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.

- Dave




view thread (8+ messages)  latest in thread

Message-ID: <508052F6.20803@grammatech.com>
Permalink:  ../508052F6.20803@grammatech.com/
Also on:    postgresql.org/message-id/508052F6.20803@grammatech.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: dvitek@grammatech.com, hlinnakangas@vmware.com, tgl@sss.pgh.pa.us
  Subject: Re: Fwd: race in pg_ctl start -w
  In-Reply-To: <508052F6.20803@grammatech.com>
  References: <5076F626.2090404@grammatech.com> <5076FF23.6020704@iki.fi> <22107.1349976592@sss.pgh.pa.us> <50771713.8000908@vmware.com> <25454.1349984162@sss.pgh.pa.us> <507BC402.40807@vmware.com> <508052F6.20803@grammatech.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox