[Fontconfig-bugs] [Bug 101889] Make fontconfig cache relocatable
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Wed Dec 20 09:06:09 UTC 2017
https://bugs.freedesktop.org/show_bug.cgi?id=101889
--- Comment #84 from Alexander Larsson <alexl at redhat.com> ---
Actually, not even that is enough to make it threadsafe.
Fundamentally, you can't do something like return the values from
FcHashTableFind() while at the same time allow replacing them, because at any
time after you looked up a value it may become replaced and the value freed.
This is true even if you have a value_copy_func, for example in
FcHashTableFind, where the value in the table could be freed by another thread
doing a replace inbetween reading the bucket->value and calling value_copy_func
on it.
Also, if you're doing atomic replace on bucket->value, you need to pair that
with reading it with get_atomic.
I'm not sure why you are writing lock-less code like this, it is a *lot* of
work to make it correct, especially on non-intel boxes that don't have strong
ordering, and adding a bunch of atomic ops everywhere is likely to be slower
than just a single lock around the entire thing unless it is actually highly
contended.
Anyway, given the current API i think the only solution is to make replace just
add *more* values for the key, basically making FcHashBucket->value a list.
That way old values are not freed, but just "deprecated".
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/fontconfig-bugs/attachments/20171220/1e3987f4/attachment.html>
More information about the Fontconfig-bugs
mailing list