diff options
author | Colin Cross <ccross@android.com> | 2017-06-22 14:19:18 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2017-06-22 14:21:52 -0700 |
commit | 76464d958bd17f365e16c0dcb2d3123aab67c36a (patch) | |
tree | 16ba7ed2f1dd2e8009dfda43067c8b9a22465e4a /libmemunreachable | |
parent | f3ce8bc8aed76b07d928971e627e21c81be75e91 (diff) | |
download | system_core-76464d958bd17f365e16c0dcb2d3123aab67c36a.tar.gz system_core-76464d958bd17f365e16c0dcb2d3123aab67c36a.tar.bz2 system_core-76464d958bd17f365e16c0dcb2d3123aab67c36a.zip |
Fix stack test on arm32
The stack test puts a pointer to an allocation on the stack, checks
that there are no leaks, then lets it go out of scope and checks
that libmemunreachable can find a leak. This works on arm64, but
on arm32 the pointer on the stack doesn't get overwitten and the
leak is not detected. Rewrite the pointer to be NULL instead.
Test: memunreachable_test
Change-Id: I5959a34cbb572a5d8670270077a85d247a3a4880
Diffstat (limited to 'libmemunreachable')
-rw-r--r-- | libmemunreachable/tests/MemUnreachable_test.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libmemunreachable/tests/MemUnreachable_test.cpp b/libmemunreachable/tests/MemUnreachable_test.cpp index bb6bcbc7a..ec8938885 100644 --- a/libmemunreachable/tests/MemUnreachable_test.cpp +++ b/libmemunreachable/tests/MemUnreachable_test.cpp @@ -40,7 +40,8 @@ class HiddenPointer { volatile uintptr_t ptr_; }; -static void Ref(void* ptr) { +// Trick the compiler into thinking a value on the stack is still referenced. +static void Ref(void** ptr) { write(0, ptr, 0); } @@ -58,14 +59,14 @@ TEST(MemunreachableTest, stack) { { void* ptr = hidden_ptr.Get(); - Ref(ptr); + Ref(&ptr); UnreachableMemoryInfo info; ASSERT_TRUE(GetUnreachableMemory(info)); ASSERT_EQ(0U, info.leaks.size()); - Ref(ptr); + ptr = nullptr; } { |