Re: Allowing printf("%m") only where it actually works

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Allowing printf("%m") only where it actually works
Date: 2018-05-27 01:00:33
Message-ID: 2576.1527382833@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.postgresql.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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2018-05-27 05:04:50 Re: Allowing printf("%m") only where it actually works
Previous Message Tom Lane 2018-05-27 00:38:03 Re: Allowing printf("%m") only where it actually works