[PATCH v2] Fix double-checked locking in __gconv_get_path and __gconv_read_conf [BZ #22062]
Florian Weimer
fweimer@redhat.com
Fri Oct 6 06:38:00 GMT 2017
On 10/06/2017 01:05 AM, Carlos O'Donell wrote:
> Is there any reason we need this atomic load?
>
>> + gconv_path_elem_local = atomic_load_relaxed (&__gconv_path_elem);
> ^^^^^^^^^^^^^^^^^^^
Oh, this follows just the general rule that if atomics are used, all
accesses should employ atomics. This follows from the general principle
of C11 compatibility, where an atomic type would default to seq-cst
access (which we don't want here). I see this was not mentioned in the
Concurrency wiki page. I've fixed that.
I did not notice that there was a __libc_once guard. So it would be
better to remove the locking from __gconv_get_path and document that
(including that this serializes initialization of the gconv cache via
__gconv_load_cache).
Thanks,
Florian
More information about the Libc-alpha
mailing list