<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>Hi Alex,</p>
<p><br>
</p>
<p>thanks for the quick response.</p>
<p><br>
</p>
<p>Yes that answers my question. I'll investigate the thread-safety issues and will decide if it's worth trying to make libclang thread-safe.</p>
<p><br>
</p>
<p></p>
<p>Thanks,</p>
<p>Ranjeet</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Alex L <arphaman@gmail.com><br>
<b>Sent:</b> 30 March 2017 15:34:28<br>
<b>To:</b> Ranjeet Singh<br>
<b>Cc:</b> cfe-dev@lists.llvm.org; nd<br>
<b>Subject:</b> Re: [cfe-dev] [libclang] thread safety issue</font>
<div> </div>
</div>
<div>
<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>
</div>
</div>
</body>
</html>