aboutsummaryrefslogtreecommitdiff
path: root/libc/malloc_debug
Commit message (Collapse)AuthorAgeFilesLines
* Use SKIP_WITH_HWASAN macro from libbase.Florian Mayer2022-04-153-2/+2
| | | | Change-Id: I83681d2191bf4184e52d84d1107d61065927bb24
* Skip verify_leak_allocation_limit under HWASan.Florian Mayer2022-04-142-0/+3
| | | | | Bug: 227801493 Change-Id: I85630fe11b42d8d45ce63f279bb0fbcc635f8afb
* Skip mallinfo / malloc_info tests on HWASan.Florian Mayer2022-04-062-0/+4
| | | | | | | Those aren't implemented. Test: passes on forrest. Change-Id: I1a00f5e8ff1aba8f0e25ce589281ed3bfa9d0a5c
* Update for LocalUnwinder object removal.Christopher Ferris2022-03-038-41/+65
| | | | | | | | | | | | | | Modify libfdtrack to use the normal Unwinder object. In addition, update the libfdtrack so that it doesn't record frames in libfdtrack.so rather than skipping frames it thinks will be in the library. Modify the malloc debug code to use the normal Unwinder object. Bug: 120606663 Test: All unit tests pass. Change-Id: I3c9612dd10e62389e6219e68045ee87f7b2625f5
* Add documentation about Android 12 bug.Christopher Ferris2022-03-021-0/+7
| | | | | | | | The wrap.<APP> property was broken in Android 12, so provide documentation about how to workaround it. Test: NA Change-Id: I98fdc5801997492442802e1295fb6969f9190e1c
* Fix possible nullptr dereference.Christopher Ferris2022-02-021-2/+4
| | | | | Test: Unit tests pass. Change-Id: I046c6e1665de4d941362e2f65605609e77731c97
* Update for libunwindstack shared_ptr MapInfos.Christopher Ferris2021-10-292-12/+11
| | | | | | | | | Bug: 120606663 Test: Malloc debug unit tests pass. Change-Id: Ic8fa25c770953ebc0a78d67e54bc0d7b8e0abd87 Merged-In: Ic8fa25c770953ebc0a78d67e54bc0d7b8e0abd87 (cherry picked from commit 04233539b49d699972ec16277764513cb170c912)
* Remove libc++demangle from static libs.Liz Kammer2021-10-121-6/+0
| | | | | | | | This is implicitly added by Soong with stl https://cs.android.com/android/platform/superproject/+/master:build/soong/cc/stl.go;l=157;drc=cb0ac95bde896fa2aa59193a37ceb580758c322c Test: m Change-Id: Ie18a7cda8001deb3a0e714db02a50919e631c319
* Revert "strerror: incl enum name"Steven Moreland2021-10-072-3/+2
| | | | | | | | | | | | | Revert submission 1833622-usable-strerror Reason for revert: b/202330586 Bug: 202330586 Reverted Changes: I4d8f617a0:Track strerror(3) change. I8ea86220c:strerror: incl enum name I407bd9f4d:strerror: incl enum name Change-Id: I81ed563221a77827084711eadd7fb739aeba52a1
* strerror: incl enum nameSteven Moreland2021-10-052-2/+3
| | | | | | | | | | | | strerror is nice, but usually I don't care about the text, I care about the uppercase enum Bug: N/A Test: ./tests/run-on-host.sh glibc (existing failures -> b/201305529) Test: atest bionic-unit-tests-static Test: atest malloc_debug_unit_tests Change-Id: I407bd9f4dfa918fff66a0da7df8d7239f789c7b8
* Add more tests to TEST_MAPPINGColin Cross2021-10-011-0/+1
| | | | | Test: treehugger Change-Id: I1d7dd32fd7f90a20d61de4701293527f83dc4ec4
* Only run the exec once if test passes.Christopher Ferris2021-08-051-2/+14
| | | | | | | | | | | | | | I accidentally made the tests run MAX_RETRIES times instead of running once when passing, and at most MAX_RETRIES when the test fails. Also, add a bit of randomness to the usleep to try and avoid tests syncing up on failures. Bug: 193898572 Test: Ran unit tests and verified that a pass doesn't result in another run. Test: Ran three copies of the unit tests at the same time to verify that Test: there isn't a flaky test failure. Change-Id: I8b8d3cd05ca7d1e87ce34bf10aeef84f6989fdab
* Allow retry of test if log missing.Christopher Ferris2021-07-271-66/+105
| | | | | | | | | | | | | | | | | | | Refactor the code a bit to allow retrying if a log message is missing. This is because there is a possibility of a log message getting dropped. If that happens, merely rerun up to three times and pass if the missing message is present. Also fix a race condition that can occur if the LogReader threads are being terminated but happen to be allocating memory while they are in the signal handler. This situation causes aborts in the memory allocator or a deadlock. Before this change, the verify_leak* tests would fail in less than twenty iterations. After, I could run for hundreds of iterations. Bug: 193898572 Test: Ran unit tests in a loop. Change-Id: I0fb5beab6041dcf3e3fd19f6748bb20bb81a2506
* Read the log while test runs instead of after.Christopher Ferris2021-07-231-225/+323
| | | | | | | | | | | | | | | | | | | | | | | | These tests can be flaky if something is spamming the log and expiring messages. Previously, the log wasn't read until the forked process was complete. Now, two threads are spawned right after the process forks to read the log while running. This should avoid any problems if the log is being spammed while the test runs. In addition, fixed some potential flakiness in the test that might occur if the test incorrectly gets stale log data. Bug: 193898572 Test: All unit tests pass on cuttlefish (both 32 bit and 64 bit). Test: Forced an abort and verified that the crash log reader sees Test: the message. Test: Verified that the log reader for the main and crash log properly Test: read data. Test: Verified the test passes while swamping the log by running Test: the log unit tests while running two copies of the system Test: tests. Change-Id: I68bd92a8c483eac0146ada87dd4201dda0902c49
* Avoid undefined compiler behaviorChristopher Ferris2021-07-151-1/+1
| | | | | | | | | | | This is a follow-on to commit 5358cc40ab4288ed00c223f00cf898b7dc1a9484. I forgot that there were two places the undefined behavior could occur. Make the literal unsigned in the other place. Test: TreeHugger Bug: 189541929 Change-Id: Iaef81507ca61e802d277246bf5995157c93d86ce
* Avoid undefined compiler behaviorGreg Kaiser2021-07-151-1/+1
| | | | | | | | | | | | | | Technically, shifting a signed value beyond its maximum range is undefined behavior in C++. A bare integer literal is signed, and defaults to 'int'. On platforms where 'int' is 32-bits, we shift outside this range with 1 << 31. We make our literal an unsigned integer to avoid this. Test: TreeHugger Bug: 189541929 Change-Id: Iade1bcd3f86d025dd6e10c26622d10c26e2c8295
* Fix race when frees after main thread finishes.Christopher Ferris2021-07-142-9/+65
| | | | | | | | | | | | | | | | | | | | | When the main thread is exiting, the code deleted the g_debug global pointer and destroys the disable pthread key. Unfortunately, if malloc debug was enabled in a way that requires a header for the pointer, any frees that occur after the main thread is torn down result in calls to the underlying allocator with bad pointers. To avoid this, don't delete the g_debug pointer and don't destroy the disable pthread key. Added a new system test that allocates a lot of pointers and frees them after letting the main thread finish. Also, fix one test that can fail sporadically due to a lack of unwinding information on arm32. Bug: 189541929 Test: Passes new system tests. Change-Id: I1cfe868987a8f0dc880a5b65de6709f44a5f1988
* Stop documenting native_heapdump_viewer.Elliott Hughes2021-06-241-24/+0
| | | | | | | | | | ...since we're removing it anyway. We recommend Perfetto instead. Bug: https://github.com/android/ndk/issues/435 Test: treehugger Change-Id: If932646d869f7df6bbe147b5dce49abdd9f31612
* Update API of MapInfo from libunwindstackDavid Srbecky2021-05-132-7/+7
| | | | | | | Use accessors to for all the fields. Test: build Change-Id: I6ae458002e059ef2f9d73931cc68f2f698f85d7e
* Add LOCAL_LICENSE_KINDS to bionicBob Badour2021-02-191-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added SPDX-license-identifier-Apache-2.0 to: apex/Android.bp libdl/Android.bp tools/Android.bp tools/versioner/Android.bp tools/versioner/src/Android.bp Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to: benchmarks/Android.bp benchmarks/linker_relocation/gen/Android.bp libc/malloc_debug/Android.bp libc/system_properties/Android.bp tests/Android.bp tests/libs/Android.bp tests/libs/Android.build.dlext_testzip.mk tests/make_fortify_compile_test.mk Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD SPDX-license-identifier-ISC SPDX-license-identifier-MIT legacy_notice legacy_unencumbered to: libc/Android.bp Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD SPDX-license-identifier-MIT legacy_unencumbered to: libm/Android.bp Added SPDX-license-identifier-Apache-2.0 legacy_unencumbered to: libc/tools/Android.bp Added SPDX-license-identifier-BSD to: benchmarks/linker_relocation/Android.bp benchmarks/spawn/Android.bp libc/async_safe/Android.bp libc/malloc_hooks/Android.bp libfdtrack/Android.bp linker/Android.bp tests/headers/Android.bp tests/headers/posix/Android.bp Bug: 68860345 Bug: 151177513 Bug: 151953481 Test: m all Exempt-From-Owner-Approval: janitorial work Change-Id: Ib05bcaa276b3aa71a7654ccbe8e67e1f16aec9f3
* Revert "[LSC] Add LOCAL_LICENSE_KINDS to bionic"Elliott Hughes2021-02-161-10/+0
| | | | | | | | This reverts commit 48d43034d7b5a419ba56f052856696d53a7bd979. Reason for revert: bionic is multiple projects, not just one. Change-Id: Ib31e1bb8888cc85c6e7736c4e2a1d4652fd23935
* [LSC] Add LOCAL_LICENSE_KINDS to bionicBob Badour2021-02-121-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added SPDX-license-identifier-Apache-2.0 to: libdl/Android.bp tools/versioner/src/Android.bp Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to: benchmarks/Android.bp libc/malloc_debug/Android.bp libc/system_properties/Android.bp linker/Android.bp tests/Android.bp tests/libs/Android.bp tests/libs/Android.build.dlext_testzip.mk tests/make_fortify_compile_test.mk Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD SPDX-license-identifier-ISC SPDX-license-identifier-MIT legacy_notice legacy_unencumbered to: Android.bp libc/Android.bp Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD SPDX-license-identifier-ISC SPDX-license-identifier-MIT legacy_unencumbered to: tools/Android.bp tools/versioner/Android.bp Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD SPDX-license-identifier-MIT legacy_unencumbered to: libm/Android.bp Added SPDX-license-identifier-Apache-2.0 legacy_unencumbered to: libc/tools/Android.bp Added SPDX-license-identifier-BSD to: benchmarks/linker_relocation/Android.bp benchmarks/spawn/Android.bp libc/async_safe/Android.bp libc/malloc_hooks/Android.bp libfdtrack/Android.bp tests/headers/Android.bp tests/headers/posix/Android.bp Added legacy_notice to: apex/Android.bp benchmarks/linker_relocation/gen/Android.bp Bug: 68860345 Bug: 151177513 Bug: 151953481 Test: m all Exempt-From-Owner-Approval: janitorial work Change-Id: I76cad00578b9b99180ee5dd1e04b4646d5c5fedf
* alloc_debug: get load_bias errorWeiwei.Zhang2020-09-281-2/+5
| | | | | | | | | | | | | | | | | malloc_debug can use libunwind and libunwindstck to unwind backtrace, if libc.debug.malloc.options contains the string of "backtrace_full", malloc_debug will use libunwindstck, and if libc.debug.malloc.options contains the string of "backtrace=*", malloc_debug will use libunwind. The result of libunwindstck is normal, but the result of libuniwnd is abnormal, there is a offset between the rel_cp and the correct value, so addr2line can't decode the right line number. Libunwind and libunbiwndpack calculate load_bias is different, so malloc_debug get load_bias alignment with libunwindstack. Bug: 169539402 Change-Id: I640fb5db39af622a0bb52abf2c107984065a89d5
* Fix deadlock/timeout in thread unwinding.Christopher Ferris2020-05-203-2/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | When malloc debug is enabled, using libbacktrace to unwind can result in a deadlock. This happens when an unwind of a thread is occuring which triggers a signal to be sent to that thread. If that thread is interrupted while a malloc debug function is executing and owns a lock, that thread is then stuck in the signal handler. Then the original unwinding thread attempts to do an allocation and gets stuck waiting for the same malloc debug lock. This is not a complete deadlock since the unwinder has timeouts, but it results in truncated unwinds that take at least five seconds to complete. Only the backtrace signals needs to be blocked because it is the only known signal that will result in a thread being paused in a signal handler. Also, added a named signal in the reserved signal list for the special bionic backtrace signal. Bug: 150833265 Test: New unit tests pass with fix, fail without fix. Change-Id: If3e41f092ebd40ce62a59ef51d636a91bc31ed80
* Include log/log_read.h for reading logsTom Cherry2020-04-221-1/+1
| | | | | | | | log/log.h is concerned with writing logs. Bug: 78370064 Test: build Change-Id: I03d35f47acaa6eb0c8865836767d855be0203e92
* Remove ANDROID_LOG_RDONLYTom Cherry2020-03-231-1/+1
| | | | | | | This macro hasn't been meaningful in years. Test: logging unit tests Change-Id: I849a466052524c24f1dba585a6423e80198c6b9c
* Merge "Add tagged pointers to bionic."Evgenii Stepanov2020-01-241-0/+2
|\
| * Add tagged pointers to bionic.Mitch Phillips2020-01-231-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces tagged pointers to bionic. We add a static tag to all pointers on arm64 compatible platforms (needs requisite top-byte-ignore hardware feature and relevant kernel patches). We dynamically detect TBI-compatible devices (a device with the TBI feature and kernel support) at process start time, and insert an implementation-dependent tag into the top byte of the pointer for all heap allocations. We then check that the tag has not been truncated when deallocating the memory. If an application incorrectly writes to the top byte of the pointer, we terminate the process at time of detection. This will allow MTE-incompatible applications to be caught early. Bug: 135754954 Bug: 147147490 Test: cd bionic && atest . Change-Id: Ie424325ba1e3c4443040ac265aeaa28d9e405d28
* | Update for change MapInfo constructor.Christopher Ferris2020-01-221-1/+2
|/ | | | | | | Bug: 148075852 Test: Ran unit tests. Change-Id: I8326d8db9887e2bba26d6d94786a72c49edc5d21
* Merge "Export the unwinder implementation from libc."Peter Collingbourne2020-01-211-8/+0
|\
| * Export the unwinder implementation from libc.Peter Collingbourne2020-01-101-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This supports the soong commit which causes most platform binaries to stop statically linking against the unwinder implementation. The soong commit message has more motivation for this change. ARM32 uses LLVM libunwind, while all other platforms use libgcc as the unwinder implementation. This matches the current choices of unwinders on the various architectures, but means that apps which were directly linking against the libc.so unwinder symbols on ARM32 are now using LLVM libunwind instead of libgcc. Set libc_headers sdk_version to 1 so that libunwind_llvm can depend on it, and stop statically linking libunwind into libc_malloc_debug. Bug: 144430859 Change-Id: I52c7f7893d93f500383aeb0b76086c3b6f1935a5
* | Revert "Add tagged pointers to bionic."Nicolas Geoffray2020-01-211-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 43d5f9d4dd83d15a859d9be1359c4a4a47381fea. Bug: 135754954 Bug: 147147490 Exempt-From-Owner-Approval: clean revert Reason for revert: Breaks ART gtest, see: https://ci.chromium.org/p/art/builders/ci/angler-armv8-non-gen-cc/561 The crash happens on mprotect of a page, the test crashes with ENOMEM. Change-Id: I52eea1abbfaf8d8e2226f92d30aa55aba3810528
* | Add tagged pointers to bionic.Mitch Phillips2020-01-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces tagged pointers to bionic. We add a static tag to all pointers on arm64 compatible platforms (needs requisite top-byte-ignore hardware feature and relevant kernel patches). We dynamically detect TBI-compatible devices (a device with the TBI feature and kernel support) at process start time, and insert an implementation-dependent tag into the top byte of the pointer for all heap allocations. We then check that the tag has not been truncated when deallocating the memory. If an application incorrectly writes to the top byte of the pointer, we terminate the process at time of detection. This will allow MTE-incompatible applications to be caught early. Bug: 135754954 Bug: 147147490 Test: cd bionic && atest . Change-Id: I6e5b809fc81f55dd517f845eaf20f3c0ebd4d86e
* | Move bionic_macros.h from private to platform.Josh Gao2020-01-029-9/+9
|/ | | | | Test: treehugger Change-Id: Ie473914f4c8924c7240b3ac22093a9daf42fc948
* Add automatic running of tests on bionic changes.Christopher Ferris2019-11-152-6/+19
| | | | | | | | | | | | | | | | | | | malloc debug and malloc hooks have been broken for a long time and no one noticed. So add them to be run by default on bionic changes since that provides the most coverage. Change the malloc debug and malloc hooks tests to support isolated runs. Changed the name of the malloc hooks unit tests to system tests because they weren't really unit tests. Changed the verify leak malloc debug tests to print out extra information so it is possible to figure out what sized allocation failed. Test: Ran tests. Change-Id: Idea4c864f1d62598148ee78d7c9397e45234b1ca
* Rename iterate to malloc_iterate internally.Christopher Ferris2019-11-083-6/+6
| | | | | | | | | | | | I have no idea why I used the iterate name internally which is completely unlike every other function name. Change this to match everyone else so that it's now malloc_iterate everywhere. This is probably the last chance to change this before mainline modules begin, so make everything consistent. Test: Compiles, unit tests passes. Change-Id: I56d293377fa0fe1a3dc3dd85d6432f877cc2003c
* Fix allocations escaping malloc debug.Christopher Ferris2019-11-065-63/+264
| | | | | | | | | | | | | | | | | | | | | | When using a FILE object for some malloc debug functions, calling fprintf will trigger an allocation to be put in the object. The problem is that these allocations were not allocated by the malloc debug wrapper and they get freed during the fclose as if they are malloc debug allocation. In most cases, the code will detect the bad pointer and leak the memory, but it might also cause a crash. The fix is to avoid using fprintf so that no allocations are made in the object that survive and need to be freed in the fclose call. Change the MallocXmlElem.h to use a file decsriptor not a FILE object. Add new unit and system tests to detect this case. Bug: 143742907 Test: Ran unit and system tests. Test: Ran bionic unit tests. Change-Id: I524392de822a29483aa5be8f14c680e70033eba2
* libc_malloc_[debug|hooks] are not available for platformJiyong Park2019-10-071-1/+5
| | | | | | | | | | | | | | The libs are not available for platform. Thus removing '//apex_available:platform' from the apex_available property. However, since there are test modules that statically links the libs, we exceptionally make the static variant of the libs available to the platform. Test: m Test: mm under bionic does not create out/target/product/<name>/system/lib[64]/libc_malloc_[debug|hooks].so Change-Id: Ia6d473658c4231b04b5db511f9dacbbdf0f207b0
* Restrict the availability of the bionic libsJiyong Park2019-10-071-0/+10
| | | | | | | | | | The bionic libs are now restricted to be in the runtime APEX and the platform (for bootstrapping). It can still be referenced from other APEXes but can't be included there. Bug: 139870423 Test: m Change-Id: I7f99eef27ccf75844ca5c9a7ea866496841b738f
* Make bionic_malloc.h a platform header.Christopher Ferris2019-09-162-2/+12
| | | | | | | | | | | | Instead of having platform directories directly include the private header, create a platform header directory and export it. Bug: 130763340 Test: Builds. Change-Id: Ie0f092b3fe077a3de8b90266c0b28bfbc20d0dfa Merged-In: Ie0f092b3fe077a3de8b90266c0b28bfbc20d0dfa (cherry picked from commit 8f582ef2f8a77d953d0e9f33387f592d20f852e2)
* Link libc++demangle.Dan Albert2019-07-241-0/+6
| | | | | | | | The demangler is moving out of libc++abi to save on bloat. Test: make checkbuild Bug: http://b/138245375 Change-Id: I7402894bb326f524388c9efdf86509dad50f2018
* Move to the libc++ demangler.Christopher Ferris2019-07-184-10/+31
| | | | | | | | | | | Bug: 136138882 Test: Ran malloc debug tests. Test: Ran an app with backtrace_full and verified demangling working in Test: log file. Test: Enabled leak checking and verified that the logs include properly Test: demangled. Change-Id: Ic4fd9f1522451e867048ac1bea59d8c5ed0d3577
* Disable malloc debug when asan enabled.Christopher Ferris2019-05-221-0/+7
| | | | | | | | Bug: 123312263 Test: Verified with asan enabled, malloc debug does not initialize. Test: Ran tests on non-asan build and verify they pass. Change-Id: I3c37c170bf6c1de42740972f2113ae991351d931
* Export some symbols for vendor libmemunreachableColin Cross2019-05-171-1/+1
| | | | | | | | | Add the malloc symbols used by libmemunreachable to the VNDK, and make libc_malloc_debug_backtrace vendor_available. Bug: 132302484 Test: m checkbuild Change-Id: Ide555195afa084c13eaeaf0eab6ff90787b5f2d0
* Avoid using malloc debug code after exit.Christopher Ferris2019-05-072-10/+109
| | | | | | | | | | | | | I wrote a new unit test that would fail on the old version of the code. On a walleye big cpu, this costs about 40ns-50ns (going from ~430ns to ~480ns). I think this is an acceptable performance degradation. Bug: 131867816 Test: New unit tests pass. Change-Id: I4c0f4373fb0694bf29c3824dbb1224a8a17e211e
* Remove gMallocLeakZygoteChild.Christopher Ferris2019-04-163-17/+19
| | | | | | | | | | | | | | | Remove this global variable and change the setting of it to non-zero to a call to android_mallopt. In addition, change the initialize function to use pass a bool* instead of int*. Bug: 130028357 Test: Ran malloc_debug/malloc_hooks/perfetto tests. Change-Id: I20d382bdeaaf38aac6b9dcabea5b3dfab3c945f6 Merged-In: I20d382bdeaaf38aac6b9dcabea5b3dfab3c945f6 (cherry picked from commit 5225b342f0810c027df3d09fbbcef4d324b19b93)
* Disable info messages by default for malloc debug.Christopher Ferris2019-04-029-77/+123
| | | | | | | | | | | | Add a new option verbose for malloc debug that is not enabled by default. This disables all of the info log messages. It turns out these log messages can add a measurable amount of time and can change the boot up. Bug: 129239269 Test: Adjusted unit tests pass. Test: Verified no messages unless verbose option used. Change-Id: I805cb7c8ecb44de88119574e59d784877cacc383
* Add a platform API for setting an allocation limit.Christopher Ferris2019-03-152-8/+215
| | | | | | | | | | | | | | | | | | | | | | | | | Introduce an M_SET_ALLOCATION_LIMIT enumerator for android_mallopt(), which can be used to set an upper bound on the total size of all allocations made using the memory allocation APIs. This is useful for programs such as audioextractor and mediaserver which need to set such a limit as a security mitigation. Currently these programs are using setrlimit(RLIMIT_AS) which isn't exactly what these programs want to control. RLIMIT_AS is also problematic under sanitizers which allocate large amounts of address space as shadow memory, and is especially problematic under shadow call stack, which requires 16MB of address space per thread. Add new unit tests for bionic. Add new unit tests for malloc debug that verify that when the limit is enabled, malloc debug still functions for nearly every allocation function. Bug: 118642754 Test: Ran bionic-unit-tests/bionic-unit-tests-static. Test: Ran malloc debug tests and perfetto integration tests. Change-Id: I735403c4d2c87f00fb2cdef81d00af0af446b2bb
* Malloc debug: fix mutex deadlock issueIris Chang2019-03-081-1/+1
| | | | | | | | | | | | When we enable free_track option, one thread is in AddFreed->RemoveBacktrace flow (hold free_pointer_mutex_ first and try to lock frame_mutex_), and other thread do fork and enter PrepareFork flow (hold frame_mutex_ first and try to lock free_pointer_mutex_), this situation may result in mutex deadlock issue. Bug: 127733115 Test: build pass and stress test pass Change-Id: Ie5fcc4ef6c169372ad73d81978cfb2a726b6c03e
* Refactor the malloc_info code.Christopher Ferris2019-03-077-4/+133
| | | | | | | | | | | | | | malloc_info needs to be per native allocator, but the code treated it like a global function that doesn't depend on the native memory allocator. Update malloc debug to dump the actual pointers that it has been tracking. Test: bionic-unit-tests pass. Test: malloc debug tests pass. Test: malloc hook tests pass. Change-Id: I3b0d4d748489dd84c16d16933479dc8b8d79013e Merged-In: I3b0d4d748489dd84c16d16933479dc8b8d79013e (cherry picked from commit a3656a98b10d2a4a6194a5d9705ad9c2cc5877b0)