Commit graph

50 commits

Author SHA1 Message Date
Colin Cross
f013b62152 Remove test_suites: ["vts"] from memunreachable_binder_test
memunreachable_binder_test is pulled in by
test/vts/tools/build/tasks/list/vts_test_bin_package_list.mk, it
doesn't need to be listed in test_suites.

Fixes warnings:
build/make/core/base_rules.mk:620: warning: overriding commands for target `out/host/linux-x86/vts/android-vts/testcases/memunreachable_binder_test'
build/make/core/base_rules.mk:620: warning: ignoring old commands for target `out/host/linux-x86/vts/android-vts/testcases/memunreachable_binder_test'

Test: vts-tradefed run commandAndExit vts -m VtsKernelBinderTest
Change-Id: Ifd282b2f5bb652295fa34ad247919eb85ea7abc8
2018-03-15 14:57:22 -07:00
Colin Cross
51e6c252c4 Make memunreachable_binder_test suitable for VTS
Link statically against libmemunreachable to avoid runtime
dependency on libmemunreachable.so.
Provide a better error when run as non-root.
Rename the test to MemunreachableBinderTest.
Add comments explaining the test sequence.

Bug: 28275695
Test: memunreachable_binder_test
Change-Id: Iddfba636205b7ca3ad31a6ba2c4e85abadd32d0d
2018-02-27 18:29:18 -08:00
Elliott Hughes
dc699a269f bpfmt.
Bug: N/A
Test: builds
Change-Id: I89ad00e1c4c7e0767bc80a7ac7935a4d55e090ac
2018-02-16 17:58:14 -08:00
Daniel Colascione
b650aef2a0 Add explanation for clone use
Test: no code changes
Change-Id: I70c8af8261cda3163677557fd78ae0119b1f1be0
2018-02-08 15:07:47 -08:00
Elliott Hughes
693d63f9cf Add OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie785058c0f5eb9b4086c98ccba6e63e3ed411b65
2017-12-07 13:30:03 -08:00
George Burgess IV
80136a1e41 Silence static analyzer warnings about memory leaks
The static analyzer complains that this memory is leaked regardless of
how I try to work around it (unless we escape the memory by using a
global or something, but...). Basically, as long as there's some sort
of operation on the reinterpret_cast'ed pointer, it complains. If we
remove the bitwise negations, it doesn't. Doing so would presumably
defeat the purpose of this test, though, so add a NOLINT.

Bug: 27101951
Test: mma. No more static analyzer warning for this file.
Change-Id: If9008946a2145d17b8651535141bfd7ec9224739
2017-09-24 13:36:29 -07:00
George Burgess IV
180e5e7021 Fix static analyzer warnings
The static analyzer was complaining that we were potentially leaking
memory here (in `ASSERT_NE(ptr, nullptr)` after `new (char)`). This
wasn't correct, but it's also not possible for `new` to return nullptr
without std::nothrow.

In any case, swap to direct calls to `::operator new`, since it looks
like this test explicitly wants calls to `::operator new` to be emitted
(which the C++ standard doesn't guarantee for all `new` expressions).

Bug: 27101951
Test: mma; static analyzer warnings are gone. Also ran
memunreachable_test on marlin; no failures.
Change-Id: Ia740e41079f263040da978ba1ccc71c9c39f53fd
2017-09-12 17:01:20 -07:00
dimitry
b6ba817de4 Define current ABI string in android-base/macros.h
Test: make
Change-Id: I8200d7b3232edba43a583c5ff1e1b0f78c768f69
2017-08-23 20:46:38 +02:00
Lennart Wieboldt
cd15fc7ba8 Remove LOCAL_CLANG and clang: true
clang is the default compiler since Android nougat

Test: mma & verified it´s still build with clang
Change-Id: I34adaeef2f6558a09f26027271222bad94780507
Signed-off-by: Lennart Wieboldt <lennart.1997@gmx.de>
2017-07-25 14:29:50 +02:00
Colin Cross
454285dfcc Merge "libmemunreachable: track kernel binder references" 2017-07-13 19:41:26 +00:00
Colin Cross
f572b91c4f libmemunreachable: track kernel binder references
The kernel can hold references to binder objects that have no userspace
references.  Allow libmemunreachable to call into libbinder and
libhwbinder to get lists of kernel references.  Use undefined weak
symbols so that libmemunreachable will continue to work in processes
that do not have libbinder.

Test: memunreachable_binder_test
Bug: 28275695
Change-Id: I9eae73f2a51a49a7025ffe6309ccdc2693a2391b
2017-07-12 14:59:11 -07:00
Colin Cross
b9e74ba400 Add test config for memunreachable_test
Test: none
Change-Id: Ieb297a2fcece6365a074cd470b3ca56e2baea926
2017-07-07 01:07:05 +00:00
Colin Cross
eac4ecc34f Fix ScopedSignalHandler
I4ae2d82fdfdd58cf8ef1dfb6c401cef4ba9d3e88 broke memunreachable_test
by replacing signal_ with signal.

Test: memunreachable_test
Change-Id: I8148321e3a94530867106708a33b5b63ed867380
2017-06-29 17:13:35 -07:00
Colin Cross
76464d958b 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
2017-06-22 14:21:52 -07:00
Colin Cross
f3ce8bc8ae libmemunreachable: turn off MEM_ALOGV messages
The move to async safe logging in I3d3b2111f6f6bf8a0d7039295d34d5168c191651
caused MEM_ALOGV messages to print even when NDEBUG was set.

Test: builds
Change-Id: Ibebe69d8c96f8f2556991c1eb5446a77782d43c7
2017-06-22 13:46:56 -07:00
Colin Cross
a9939e9a23 Move libmemunreachable into namespace android
Putting libmemunreachable in the global C++ namespace was an oversight,
move it into namespace android.

Test: m -j checkbuild
Change-Id: I0799906f6463178cb04a719bb4054cad33a50dbe
2017-06-22 10:58:23 -07:00
Colin Cross
a83881e33c libmemunreachable: clang-format everything
clang-format -i --sort-includes $(find . -name "*.cpp" -o -name "*.h")

Test: builds
Change-Id: Ia8e0677fe7f3f26dddba3a851cd2dfab9f14e421
2017-06-22 10:58:05 -07:00
Elliott Hughes
199c27734f Merge "Shave a stack frame off asserts." 2017-06-21 15:09:55 +00:00
Elliott Hughes
56731b4e2f Shave a stack frame off asserts.
We can't implement MEM_LOG_ALWAYS_FATAL_IF any more, but it wasn't really
useful anyway.

Bug: N/A
Test: ran `crasher assert` and `crasher64 assert`
Change-Id: I4ae2d82fdfdd58cf8ef1dfb6c401cef4ba9d3e88
2017-06-20 17:31:29 -07:00
Martijn Coenen
ce102dd74f Remove libmemunreachable from the VNDK.
It depends on functionality in the bionic
allocator, which may get updated independently
of the vendor partition (as libc is in the LL-NDK).

Bug: 33241851
Test: builds
Change-Id: I435679843229d0d4d2e2be7bfe8c27f558a016dd
2017-06-20 10:11:55 -07:00
Colin Cross
72d3881412 Add a helpful error message if GetUnreachableMemory fails
The primary reason for GetUnreachableMemory failing is selinux
blocking system apps from ptracing themselves.  Add a helpful
error message suggesting setenforce 0.

Bug: 27945735
Test: dumpsys meminfo --unreachable com.android.systemui
Change-Id: Ibfa9507860be36dffd514f82027f7a2f8a72ac48
2017-06-15 10:57:37 -07:00
Vijay Venkatraman
52eaeb4825 Add vendor_available:true to libmemunreachable
Bug: 38244611
Test: build sailfish
Change-Id: Ieb7fdcae4b96a1e1622ba98a7cfb56a95b798452
2017-05-24 14:32:28 -07:00
Christopher Ferris
9a4f572a95 Merge "Small test fixes." 2017-05-06 06:30:41 +00:00
Christopher Ferris
47e02f429d Small test fixes.
Bug: 31919199

Test: Ran the unit tests.
Change-Id: I62bdb007f9cfa57e3faaa05993fd6e23ce32b82f
2017-05-05 17:09:49 -07:00
Yi Kong
ae797ec305 Remove unused lambda captures
Test: build
Bug: 37752547
Change-Id: Id318f412ad81b6e7de3ad644cba4405bb04f2729
2017-05-05 14:09:10 -07:00
Christopher Ferris
47dea71b16 Move all logging to use the async safe logging.
Also, add a link to the .clang-format-2 for this directory and clang
format the files that changed.

Bug: 31919199

Test: Boot bullhead.
Test: Run unit tests on bullhead. There are a few that fail, but they
Test: failed before and are not a result of this change.
Change-Id: I3d3b2111f6f6bf8a0d7039295d34d5168c191651
2017-05-03 18:04:18 -07:00
Christopher Ferris
ac225780dd Move libc_logging to libasync_safe.
Move the name of the "private/libc_logging.h" header to <async_safe/log.h>.

For use of libc_malloc_debug_backtrace, remove the libc_logging library.
The library now includes the async safe log functions.

Remove the references to libc_logging.cpp in liblog, it isn't needed because
the code is already protected by a check of the __ANDROID__ define.

Test: Compiled and boot bullhead device.
Test: Run debuggerd unit tests.
Test: Run liblog unit tests on target and host.
Test: Run libmemunreachable unit tests (these tests are flaky though).
Change-Id: Ie79d7274febc31f210b610a2c4da958b5304e402
2017-05-02 18:38:46 -07:00
Mark Salyzyn
30f991f251 liblog: use log/log.h when utilizing ALOG macros
Test: compile
Bug: 30465923
Change-Id: Id6d76510819ebd88c3f5003d00d73a0dbe85e943
2017-01-11 09:31:15 -08:00
Elliott Hughes
36e0d390a2 Rely on the platform -std default.
Bug: http://b/32019064
Test: builds
Change-Id: I18a1d816d63b64601485045070851f32d44e85eb
2016-10-10 14:31:12 -07:00
Mark Salyzyn
ff2dcd9af9 system/core Replace log/log.h with android/log.h
Should use android/log.h instead of log/log.h as a good example
to all others.  Adjust header order to comply with Android Coding
standards.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I33a8fb4e754d2dc4754d335660c450e0a67190fc
2016-09-30 12:47:05 -07:00
Dan Albert
8b31627b92 Add missing include.
Test: mm
Bug: None
Change-Id: I8be335ed677e8646d3912ac3db49451bff66eb65
2016-09-21 16:21:52 -07:00
Dan Willemsen
194edf772e Convert to Android.bp
See build/soong/README.md for more information.

I tested the following tests on a Nexus9 and linux host, and they
continued to pass:

/data/nativetest{,64}/bootstat_tests/bootstat_tests
out/host/linux-x86/bin/nativetest{,64}/bootstat_tests/bootstat_tests
/data/nativetest64/memunreachable_test/memunreachable_test
out/host/linux-x86/bin/nativetest{,64}/memunreachable_test/memunreachable_test

These continue to fail just like before this change:

/data/nativetest{,64}/sync_test/sync_test (was /system/bin/sync_test)
/data/nativetest{,64}/sync-unit-test/sync-unit-test
/data/nativetest/memunreachable_test/memunreachable_test

Test: See above
Change-Id: I691e564e0cf008dd363e3746223b153d712e024d
2016-08-26 16:19:21 -07:00
Chih-hung Hsieh
6dc68cb5f9 Merge "Fix google-explicit-constructor warnings in system/core." 2016-07-29 16:57:17 +00:00
Chih-Hung Hsieh
223bb4e21d Suppress clang-tidy performance warnings in libmemunreachable.
Bug: 30413862
Change-Id: If3ed64d2e1ca1f46599de9fe97c769f468ee1a68
Test: build with WITH_TIDY=1
2016-07-27 16:01:41 -07:00
Chih-Hung Hsieh
034c475931 Fix google-explicit-constructor warnings in system/core.
* Declare explicit conversion constructors.
* Add NOLINT for implicit conversion constructors.
* Fix also some misaligned indendations.

Bug: 28341362
Change-Id: Idf911f35923b408d92285cc1a053f382ba08c63e
Test: build with clang-tidy
2016-07-26 11:26:01 -07:00
Elliott Hughes
749ae2d32f Remove unnecessary ARRAY_SIZE macros.
Use the canonical one instead.

Change-Id: Id80f19455f37fd2a29d9ec4191c1a0af80c5c0e7
2016-06-28 14:48:45 -07:00
Chih-Hung Hsieh
eabd5108b3 Fix misc-macro-parentheses warnings in libion, libsparse, libmem*
Bug: 28705665
Change-Id: I3dd5c086787f5e48ab100a71a42109ea0e417bf9
2016-05-18 15:41:16 -07:00
Chih-hung Hsieh
7bdd6a8b5a Merge "Fix google-explicit-constructor warnings." 2016-04-30 05:10:05 +00:00
Chih-Hung Hsieh
1c563d96f0 Fix google-explicit-constructor warnings.
Bug: 28341362
Change-Id: I4504e98a8db31e0edcbe63c23f9af43eb13e9d86
2016-04-29 15:44:04 -07:00
Colin Cross
583a250830 Silently ignore duplicate heap entries
Vendor blobs on ryu mprotect heap pages, causing a single chunk mapping
to appear as multiple mappings.  The heap iterator has to expand the
requested range to cover the beginning of the chunk to find the chunk
metadata, which will lead to duplicate identical allocations being
reported from iterating over each of the split mappings.  Silently
ignore identical allocations, and only warn on non-identical allocations
that overlap.

Bug: 28269332
Change-Id: Ied2ab9270f65d00a887c7ce1a93fbf0617d69be0
(cherry picked from commit cecd64012d)
2016-04-29 15:14:06 -07:00
Colin Cross
0965c0247b Handle segfaults while walking native heap
Vendor blobs on ryu mprotect heap pages, causing segfaults when dumping
unreachable memory.  Handle segfaults within HeapWalker by mapping a
zero page over any unreadable pages.  HeapWalker runs in the forked
process, so the mapping will not affect the original process.

Bug: 28269332
Change-Id: I16245af722123f2ad467cbc6f245a70666c55544
(cherry picked from commit ba5d9ff6d9)
2016-04-29 15:14:06 -07:00
Elliott Hughes
2c5d1d7cd9 Add operator int() to unique_fd.
Change-Id: I7512559be7befbb8772d5529e06550267a2f1543
2016-03-28 12:15:36 -07:00
Colin Cross
33e601ac30 Fix mac build
Disable memunreachable_test for mac.

Change-Id: Ie9594b6e5dfc661c4d709b419dbcb7b610434a84
(cherry picked from commit e33686b7ca)
2016-03-08 14:25:23 -08:00
Colin Cross
0f10562b56 Add ABI to leak report
Add the ABI to the leak report so that it can be piped through
development/scripts/stack.

Bug: 27208635
Change-Id: I2e050a377305d48d2f904f34ea921f64e13dd00e
(cherry picked from commit 11185af983)
2016-03-07 15:52:39 -08:00
Colin Cross
c1228c7f2b Combine leaks with same stacktrace
Combine similar leaks (those with identical stack traces) into a single
leak report, and sort the resulting leaks by total leak size across all
similar leaks and their references.

Bug: 27208635
Change-Id: Ia2bf2ccf3fcbc110d1c7ba60e3b77348d1c63d8d
(cherry picked from commit 7a22e81c20)
2016-03-07 15:52:39 -08:00
Colin Cross
e4cbe0ec9a Fix allocator::map template argument ordering
allocator::map reversed Key and T from std::map

Bug: 27208635
Change-Id: I4e4db704539d01b060cb948aa573cb674da48c7d
(cherry picked from commit 4c5bccdd86)
2016-03-07 15:52:39 -08:00
Colin Cross
d6b3a2a0a3 Fold leaks that are referenced by other leaks
Find leaks that have no references at all, or are only referenced by
other leaks in the same strongly connected component, and hide all
referenced leaks.

Bug: 27208635
Change-Id: Ifbfd14e24e2ba0f8af7c1b887e57f34362720f2d
(cherry picked from commit 8e8f34c558)
2016-03-07 15:52:39 -08:00
Colin Cross
54a1610404 Compile some tests for the host
Compile some tests for the host to ease debugging with valgrind or gdb.

Bug: 27208635
Change-Id: Ib46fcfa333ceb721f26efca00b2fa60b9fba44e6
(cherry picked from commit b8e20f557f)
2016-03-07 15:52:39 -08:00
Colin Cross
b1b7923efe libmemunreachable: fix long timeout on error
The collection thread should unblock the parent when it fails in order
to prevent a 100 second timeout delay.  Also reduce the timeout to 30
seconds, and fix a few log messages.

Change-Id: I47f9ce4f645c453810fec57bef557c32a665eefb
2016-02-19 14:00:17 -08:00
Colin Cross
bcb4ed3eaa imprecise mark and sweep native memory leak detector
libmemunreachable uses an imprecise mark and sweep pass over all memory
allocated by jemalloc in order to find unreachable allocations.

Change-Id: Ia70bbf31f5b40ff71dab28cfd6cd06c5ef01a2d4
2016-02-08 17:08:49 -08:00