thread safety #128
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
Hello,
We are considering usage of libpkgconf in our build2 toolchain project, but got some concerns regarding thread safety of the library.
The documentation implies thread safety if client objects are not shared across thread boundaries. Meanwhile looking into the code it seems that's not always the case. For example get_default_pkgconfig_path() function uses static variable outbuf which effectively makes it thread-unsafe, and so pkgconf_pkg_dir_list_build() that use it becomes thread-unsafe also. Another example is pkgconf_tuple_parse() which also uses static variable varname making unsafe itself, as well as other functions that use it directly or indirectly, in particular pkgconf_pkg_find(). In the later case it is not quite clear why the variable is made static. Actually there are quite a few places where such a static buffers are used (just grep for 'static char') and can potentially be an issue.
Am I missing something, or misread the documentation and the library is not thread-safe by design? Are there any plans to change this if so?
Thanks,
Karen
hi,
right now there are still some parts of the library that are not purely thread safe. the library and original pkgconf tool were not built around a threaded design, so thread safety wasn't a concern.
reducing the use of scratch buffers is on the todo list for the 1.4 series, which would resolve most thread safety concerns -- but i would suggest only one thread access a
pkgconf_client_t
handle at a time, guarded by a mutex or similar synchronization mechanism.hope that clarifies things...
If the library is not (yet) thread-safe, shouldn't this issue remain open?
i closed it after removing the scratch buffers. sharing
pkgconf_client_t
between threads remains unsafe intentionally.