On Fri, Nov 8, 2013 at 2:43 PM, Andy Polyakov via RT <r...@openssl.org> wrote:
>> Alternatives would be (a) using a new lock for safe static initialization,
>> or (b) more code duplication to avoid the need for an explicit pointer
>> (there could be two separate implementations for the higher-level
>> routines).  However, given the 1% performance penalty, that's a minor issue
>> at this point.
>
> While if (functiona==NULL || functionb==NULL) { asssign functiona,
> functionb } can be unsafe, I'd argue that if (functiona==NULL) { assign
> functiona } followed by if (functionb) { assign functionb } is.

That's not thread-safe.  There's no memory barrier so the writes can
be reordered.  The compiler itself could reorder those instructions.

Nico
--
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to