<div dir="ltr">Hi Chandler,<br><div><br>Ok, this object is reachable and is never deallocated. Is it design decision or a piece of legacy code? <br>We can deallocate it via llvm::ManagedStatic<> at the shutdown. Similar to next object: <br>static llvm::ManagedStatic<llvm::sys::SmartMutex<true> > SymbolsMutex;<br>This SymbolsMutex are used in static functions of  DynamicLibrary module. We already rely on this ownership routines for static variables.<br><br>This patch fixes legacy code and deallocates object stored in static variable.<br>It looks like the patch requires some changes.<br>How I should rewrite it?<br><br>There is already accepted patch with similar changes:<br><a href="https://github.com/llvm-mirror/llvm/commit/b4b9b3b24c03f414c54f55e1b34b4d9124c55883">https://github.com/llvm-mirror/llvm/commit/b4b9b3b24c03f414c54f55e1b34b4d9124c55883</a><br>This patch is a finish of his work.<br><br></div><div>Thanks,</div><div>Pavel K<br><br><br><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-04-14 17:56 GMT+03:00 Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Please see the comments David sent to the mailing list about this patch. I've quoted them below:<br>
<span class=""><br>
> This is one of those "what is a leak" existential questions.<br>
<br>
><br>
<br>
> There are two common attitudes/interpretations:<br>
<br>
><br>
<br>
</span>> 1. Memory that is unreachable<br>
<br>
> 2. Memory that is never deallocated<br>
<span class="im HOEnZb"><br>
><br>
<br>
> Most tools have been taught to only report (1) and ignore (2).<br>
<br>
><br>
<br>
> This idiom (allocating and never deallocating globals) is sometimes used to avoid global destructors which can be dangerously racy (if a multithreaded program is shutting down (possibly due to exceptions, etc) and hasn't stopped all its worker threads, it could be problematic to try to destroy globals that may still be in use by other threads - leading to failure-on-failure modes that can make debugging the original failure more difficult)<br>
<br>
<br>
<br>
</span><div class="HOEnZb"><div class="h5"><a href="http://reviews.llvm.org/D8838" target="_blank">http://reviews.llvm.org/D8838</a><br>
<br>
EMAIL PREFERENCES<br>
  <a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
<br>
<br>
</div></div></blockquote></div><br></div>