From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Thomas Munro <thomas.munro@gmail.com>
Subject: Re: using explicit_bzero
Date: Tue, 13 Aug 2019 10:33:01 +0200
Message-ID: <9ff665f5-bdd1-7aa5-9490-b77d95ef771f@2ndquadrant.com> (raw)
In-Reply-To: <20190730055805.vt4tltu6vytybbyk@alap3.anarazel.de>
References: <20190717211931.GA906@alvherre.pgsql>
<25152.1563403539@sss.pgh.pa.us>
<2751372e-e443-479a-0403-c414eae8e14e@2ndquadrant.com>
<9903.1563820532@sss.pgh.pa.us>
<4625063f-ed70-1996-1f58-bfce2375dd83@2ndquadrant.com>
<20190730055805.vt4tltu6vytybbyk@alap3.anarazel.de>
On 2019-07-30 07:58, Andres Freund wrote:
> I think it's better to have a pg_explicit_bzero or such, and implement
> that via the various platform dependant mechanisms. It's considerably
> harder to understand code when one is surprised that a function normally
> not available is called, the buildsystem part is really hard to
> understand (with runtime and code filenames differing etc), and invites
> API breakages. And it's not really more work to have our own name.
explicit_bzero() is a pretty established and quasi-standard name by now,
not too different from other things in src/port/.
>> +/*
>> + * Indirect call through a volatile pointer to hopefully avoid dead-store
>> + * optimisation eliminating the call. (Idea taken from OpenSSH.) We can't
>> + * assume bzero() is present either, so for simplicity we define our own.
>> + */
>> +
>> +static void
>> +bzero2(void *buf, size_t len)
>> +{
>> + memset(buf, 0, len);
>> +}
>> +
>> +static void (* volatile bzero_p)(void *, size_t) = bzero2;
>
> Hm, I'm not really sure that this does that much. Especially when the
> call is via a function in the same translation unit.
This is the fallback implementation from OpenSSH, so it's plausible that
it does something. It's worth verifying, of course.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: peter.eisentraut@2ndquadrant.com, andres@anarazel.de, tgl@sss.pgh.pa.us, alvherre@2ndquadrant.com, thomas.munro@gmail.com
Subject: Re: using explicit_bzero
In-Reply-To: <9ff665f5-bdd1-7aa5-9490-b77d95ef771f@2ndquadrant.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