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. Since the deleter is a NOP it gets leaked and ASAN reports it. I'm going to follow up with a better test that ASAN doesn't complain about.
On Wed, Jun 1, 2016 at 7:49 PM, Arthur O'Dwyer <arthur.j.odw...@gmail.com> wrote: > I don't get it. If this code doesn't pass ASAN, or if it leaks anything, > doesn't that indicate a bug in the library implementation of C++1z > shared_ptr? I can't find where this code does anything sneaky that a > sanitizer ought to care about... > On Jun 1, 2016 6:15 PM, "Eric Fiselier via cfe-commits" < > cfe-commits@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@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits