pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: nelson@monkey.org
Cc: pgsql-bugs@postgresql.org
Cc: pgsql-hackers@postgresql.org
Subject: Re: BUG #8167: false EINVAL -22 for opening a file
Date: Thu, 16 May 2013 11:55:10 -0400
Message-ID: <15677.1368719710@sss.pgh.pa.us> (raw)
In-Reply-To: <E1UcmpR-0004nn-2i@wrigleys.postgresql.org>
References: <E1UcmpR-0004nn-2i@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

nelson@monkey.org writes:
> RhodiumToad asked me to report "pg in PathNameOpenFile / mdopen is
> assuming that errno is preserved over calls to free() which is not
> required by the spec"

Good catch!  The proximate problem appears to be this bit in
PathNameOpenFile:

	vfdP->fd = BasicOpenFile(fileName, fileFlags, fileMode);

	if (vfdP->fd < 0)
	{
		FreeVfd(file);
		free(fnamecopy);
		return -1;
	}

The other code layers in this stack seem to be careful about preserving
errno where needed, but this bit isn't.

I've not really reviewed fd.c for other instances of the same bug,
but I do see some places where there are DO_DB(...) debug calls in
places where errno had better not change.  I'm thinking maybe we should
improve that macro to include save/restore errno.  Or else rip that
stuff out entirely --- I've sure never built this code with FDDEBUG
set, has anyone else?

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (5+ messages)  latest in thread

Message-ID: <15677.1368719710@sss.pgh.pa.us>
Permalink:  ../15677.1368719710@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/15677.1368719710@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, nelson@monkey.org, pgsql-hackers@postgresql.org
  Subject: Re: BUG #8167: false EINVAL -22 for opening a file
  In-Reply-To: <15677.1368719710@sss.pgh.pa.us>
  References: <E1UcmpR-0004nn-2i@wrigleys.postgresql.org> <15677.1368719710@sss.pgh.pa.us>

* 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