[cfe-dev] [libclang] thread safety issue
Alex L via cfe-dev
cfe-dev at lists.llvm.org
Thu Mar 30 07:34:28 PDT 2017
AFAIK CIndex is not thread-safe in general, so it's probably not worth
fixing. Note that even though the implementation of CIndex might dispatch
work to other threads, it will actually wait for them to complete, so it
won't race as long as its API is used by a single thread.
I hope this helps,
Alex
On 30 March 2017 at 15:23, Ranjeet Singh via cfe-dev <cfe-dev at lists.llvm.org
> wrote:
> Hi,
>
>
> I've found a potential race condition that can happen in the following
> code on variable ResourcesPath in tools/libclang/CIndexer.cpp
>
>
> const std::string &CIndexer::getClangResourcesPath() {
> // Did we already compute the path?
> if (!ResourcesPath.empty())
> return ResourcesPath;
>
> SmallString<128> LibClangPath;
>
> ....
> // Cache our result.
> ResourcesPath = LibClangPath.str();
> return ResourcesPath;
> }
>
> Variable ResourcesPath isn't synchronized on so it's possible that another
> thread might update ResourcesPath at the same time. Is it worth fixing this
> or is libclang advertised as not thread-safe so it's not worth fixing these
> types of bugs ?
>
>
> Thanks,
>
> Ranjeet
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170330/11d6d56d/attachment.html>
More information about the cfe-dev
mailing list