Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ud0WW-0004M0-Tj for pgsql-bugs@arkaria.postgresql.org; Thu, 16 May 2013 15:55:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Ud0WW-0006Ly-9S for pgsql-bugs@arkaria.postgresql.org; Thu, 16 May 2013 15:55:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ud0WV-0006Lp-Np; Thu, 16 May 2013 15:55:19 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ud0WN-0006nN-Sr; Thu, 16 May 2013 15:55:19 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id r4GFtAY4015678; Thu, 16 May 2013 11:55:10 -0400 (EDT) From: Tom Lane To: nelson@monkey.org cc: pgsql-bugs@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: BUG #8167: false EINVAL -22 for opening a file In-reply-to: References: Comments: In-reply-to nelson@monkey.org message dated "Thu, 16 May 2013 01:17:57 -0000" Date: Thu, 16 May 2013 11:55:10 -0400 Message-ID: <15677.1368719710@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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