[PATCH] [libcxxabi] Cleanup memory in tests to placate ASAN.
Eric Fiselier
eric at efcs.ca
Fri Nov 14 23:32:46 PST 2014
================
Comment at: test/catch_ptr_02.cpp:145
@@ -144,1 +144,3 @@
assert(p != 0);
+ // NOTE: delete needed to placate ASAN.
+ delete p;
----------------
dblaikie wrote:
> Could just rephrase this:
>
> vDerived d;
> try
> {
> throw &d;
>
> I assume that'd be sufficiently equivalent without having to pass owning pointers through the throw/catch?
That's essentially what the functions `test1`, `test2`, `test3`, and `test4` are doing. That is why I was hesitant to change the form.
================
Comment at: test/inherited_exception.cpp:160
@@ -159,1 +159,3 @@
assert(true);
+ // NOTE: delete needed to placate ASAN.
+ delete static_cast<Child*>(const_cast<Base2*>(c));
----------------
dblaikie wrote:
> This one could use a global variable & throwing the address of that.
I don't understand enough about libc++abi to say those would both be equivalent but I really hope they would be.
================
Comment at: test/test_vector1.cpp:238
@@ -237,1 +237,3 @@
+// Delete "three" to placate ASAN.
+ __cxxabiv1::__cxa_vec_delete3(three, 40, 8, my_destruct, my_dealloc3);
----------------
dblaikie wrote:
> & I don't understand this one well enough to figure out why 'three' needs to be handled here but 'one' and 'two' are fine... all the deletes/news seem to appear in triples, so why is this one weird?
There is a counter that throws after 15 objects have been destroyed. There are 10 objects in each of the vectors. That means the exception is throws in the call to `__cxa_vec_delete2`. I'm assuming the test checks that `two`'s memory gets freed even when there is an exception thrown during `__cxa_vec_delete2`.
http://reviews.llvm.org/D6281
More information about the cfe-commits
mailing list