<div dir="ltr">On Wed, Jun 1, 2016 at 7:00 PM, Eric Fiselier <span dir="ltr"><<a href="mailto:eric@efcs.ca" target="_blank">eric@efcs.ca</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">No the leak was my fault. The sneaky line was "std::shared_ptr<T> s(ptr, &nullDeleter);", which caused the allocation of a shared control block.</div></blockquote><div><br></div><div>But surely the control block is allocated and deallocated by libc++ behind the scenes, foolproofly?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"> Since the deleter is a NOP it gets leaked and ASAN reports it.</div></blockquote><div><br></div><div>Surely the NOP deleter applies only to the controlled object *ptr, not to the control block?  Is the supplied deleter actually used to allocate/deallocate the control block as well?</div><div><br></div><div>The controlled object *ptr is explicitly delete'd at the end of the test case, which is why it seems safe to me.</div><div><br></div><div>–Arthur</div><div><br></div><div><br></div><div><span style="color:rgb(80,0,80)">On Jun 1, 2016 6:15 PM, "Eric Fiselier via cfe-commits" <</span><a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><span style="color:rgb(80,0,80)">> wrote:</span></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ericwf<br>
Date: Wed Jun  1 20:09:12 2016<br>
New Revision: 271459<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=271459&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=271459&view=rev</a><br>
Log:<br>
Remove enable_shared_from_this test since it leaks the control block and fails with ASAN<br>
<br>
Modified:<br>
    libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp<br>
<br>
Modified: libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp?rev=271459&r1=271458&r2=271459&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp?rev=271459&r1=271458&r2=271459&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp (original)<br>
+++ libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp Wed Jun  1 20:09:12 2016<br>
@@ -88,32 +88,6 @@ int main()<br>
         }<br>
 #endif<br>
     }<br>
-    // Test LWG issue 2529 again. This time check that an expired pointer<br>
-    // is replaced.<br>
-    {<br>
-        T* ptr = new T;<br>
-        std::weak_ptr<T> weak;<br>
-        {<br>
-            std::shared_ptr<T> s(ptr, &nullDeleter);<br>
-            assert(ptr->shared_from_this() == s);<br>
-            weak = s;<br>
-            assert(!weak.expired());<br>
-        }<br>
-        assert(weak.expired());<br>
-        weak.reset();<br>
-#ifndef TEST_HAS_NO_EXCEPTIONS<br>
-        try {<br>
-            ptr->shared_from_this();<br>
-            assert(false);<br>
-        } catch (std::bad_weak_ptr const&) {<br>
-        } catch (...) { assert(false); }<br>
-#endif<br>
-        {<br>
-            std::shared_ptr<T> s2(ptr, &nullDeleter);<br>
-            assert(ptr->shared_from_this() == s2);<br>
-        }<br>
-        delete ptr;<br>
-    }<br>
     // Test weak_from_this_methods<br>
 #if TEST_STD_VER > 14<br>
     {<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>