[libcxx] r271459 - Remove enable_shared_from_this test since it leaks the control block and fails with ASAN
Arthur O'Dwyer via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 1 21:25:33 PDT 2016
On Wed, Jun 1, 2016 at 7:00 PM, Eric Fiselier <eric at efcs.ca> wrote:
> 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.
>
But surely the control block is allocated and deallocated by libc++ behind
the scenes, foolproofly?
> Since the deleter is a NOP it gets leaked and ASAN reports it.
>
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?
The controlled object *ptr is explicitly delete'd at the end of the test
case, which is why it seems safe to me.
–Arthur
On Jun 1, 2016 6:15 PM, "Eric Fiselier via cfe-commits" <
cfe-commits at lists.llvm.org> wrote:
> Author: ericwf
>>> Date: Wed Jun 1 20:09:12 2016
>>> New Revision: 271459
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=271459&view=rev
>>> Log:
>>> Remove enable_shared_from_this test since it leaks the control block and
>>> fails with ASAN
>>>
>>> Modified:
>>>
>>> libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
>>>
>>> Modified:
>>> libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
>>> URL:
>>> 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
>>>
>>> ==============================================================================
>>> ---
>>> libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
>>> (original)
>>> +++
>>> libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
>>> Wed Jun 1 20:09:12 2016
>>> @@ -88,32 +88,6 @@ int main()
>>> }
>>> #endif
>>> }
>>> - // Test LWG issue 2529 again. This time check that an expired
>>> pointer
>>> - // is replaced.
>>> - {
>>> - T* ptr = new T;
>>> - std::weak_ptr<T> weak;
>>> - {
>>> - std::shared_ptr<T> s(ptr, &nullDeleter);
>>> - assert(ptr->shared_from_this() == s);
>>> - weak = s;
>>> - assert(!weak.expired());
>>> - }
>>> - assert(weak.expired());
>>> - weak.reset();
>>> -#ifndef TEST_HAS_NO_EXCEPTIONS
>>> - try {
>>> - ptr->shared_from_this();
>>> - assert(false);
>>> - } catch (std::bad_weak_ptr const&) {
>>> - } catch (...) { assert(false); }
>>> -#endif
>>> - {
>>> - std::shared_ptr<T> s2(ptr, &nullDeleter);
>>> - assert(ptr->shared_from_this() == s2);
>>> - }
>>> - delete ptr;
>>> - }
>>> // Test weak_from_this_methods
>>> #if TEST_STD_VER > 14
>>> {
>>>
>>>
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160601/d41c39c4/attachment-0001.html>
More information about the cfe-commits
mailing list