<div dir="ltr">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.<div><br></div><div>I hope this helps,</div><div>Alex</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 30 March 2017 at 15:23, Ranjeet Singh via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div id="m_-3947132747954396585divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hi,</p>
<p><br>
</p>
<p>I've found a potential race condition that can happen in the following code on variable <span>ResourcesPath in tools/libclang/CIndexer.cpp</span></p>
<p><span><br>
</span></p>
<p><span></span></p>
<div>const std::string &CIndexer::<wbr>getClangResourcesPath() {</div>
<div>  // Did we already compute the path?</div>
<div>  if (!ResourcesPath.empty())</div>
<div>    return ResourcesPath;</div>
<div><br>
</div>
<div>  SmallString<128> LibClangPath;</div>
<div><br>
</div>
<div>....</div>
<div>  // Cache our result.</div>
<div>  ResourcesPath = LibClangPath.str();</div>
<div>  return ResourcesPath;</div>
<div>}</div>
<div><br>
</div>
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 ?
<p></p>
<p><span><br>
</span></p>
<p><span>Thanks,</span></p>
<p><span>Ranjeet</span></p>
</div>
</div>

<br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>