Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fMk36-0005dZ-Jz for pgsql-hackers@arkaria.postgresql.org; Sun, 27 May 2018 01:00:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fMk34-0001ZD-Ov for pgsql-hackers@arkaria.postgresql.org; Sun, 27 May 2018 01:00:38 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fMk34-0001Z3-Et for pgsql-hackers@lists.postgresql.org; Sun, 27 May 2018 01:00:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fMk31-0004Z9-Gp for pgsql-hackers@lists.postgresql.org; Sun, 27 May 2018 01:00:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w4R10X7l002577; Sat, 26 May 2018 21:00:33 -0400 From: Tom Lane To: Thomas Munro cc: PostgreSQL Hackers Subject: Re: Allowing printf("%m") only where it actually works In-reply-to: <1673.1527381483@sss.pgh.pa.us> References: <2975.1526862605@sss.pgh.pa.us> <14176.1526874887@sss.pgh.pa.us> <24986.1526877413@sss.pgh.pa.us> <31054.1526918600@sss.pgh.pa.us> <6025.1527351693@sss.pgh.pa.us> <1673.1527381483@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 26 May 2018 20:38:03 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2575.1527382833.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 26 May 2018 21:00:33 -0400 Message-ID: <2576.1527382833@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > ... It doesn't take much to make one nontrivial either. If > memory serves, malloc() can trash errno on some platforms such as macOS, > so even just a palloc creates a hazard of a hard-to-reproduce problem. After digging around in the archives, the closest thing that we seem to know for certain is that some versions of free() can trash errno, cf https://www.postgresql.org/message-id/flat/E1UcmpR-0004nn-2i%40wrigleys.po= stgresql.org as a result of possibly calling madvise() which might or might not succeed. But in the light of that knowledge, how much do you want to bet that malloc() can't change errno? And there's the possibility that a called function does both a palloc and a pfree ... regards, tom lane