aboutsummaryrefslogtreecommitdiff
path: root/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "strerror: incl enum name"Steven Moreland2021-10-071-1/+1
| | | | | | | | | | | | | 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-051-1/+1
| | | | | | | | | | | | 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
* Disable info messages by default for malloc debug.Christopher Ferris2019-04-021-0/+18
| | | | | | | | | | | | 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
* Bionic malloc debug: add a new option "abort_on_error"Iris Chang2019-01-221-0/+18
| | | | | | | | | | | This new option causes an abort after malloc debug detects an error. This allows vendors to get process coredumps to analyze memory for corruption. Bug: 123009873 Test: New test cases added for unit tests and config tests. Change-Id: I6b480af7f747d6a82f61e8bf3df204a5f7ba017f
* Point to online documentation.Christopher Ferris2018-05-251-105/+2
| | | | | Test: Unit tests pass. Change-Id: Ibbdc260bfdf6a6daf091c4a49cdf03e51f6ca6cf
* Add support for using the new unwinder.Christopher Ferris2018-05-241-0/+23
| | | | | | | | | | | | | | | | This adds a new option backtrace_full, when it is set, then it will use libunwindstack. Modify the dump to file data to dump the extra information from libunwindstack. Along with the new dump file format, change the version to v1.1. Updated document for new format of file data. Add unit tests for the new functionality. Bug: 74361929 Test: Ran unit tests. Change-Id: I40fff795f5346bba7b9d7fde2e04f269ff4eb7f1
* Refactor malloc debug.Christopher Ferris2018-04-021-15/+37
| | | | | | | | | | | | | | | | | | | | | | | | Changes - Refactor the code so that only guards require creating a special header for every pointer allocated. - Store only a single copy of every backtrace. This saves memory so that turning on the backtrace option doesn't result in 10X memory usage. - Added new option track_allocs that only verifies pointers are valid for free/malloc_usable_size/realloc. - Remove suffix from test names. - Add the TRACK_ALLOCS options to all guard options. - Add new option verify_pointers that is a lightweight way to verify pointers that are passed to allocation routines. - Do auto-formatting of the code. - Updated documentation for all of these changes. Bug: 74361929 Test: Ran unit tests. Test: Ran libmemunreachable unit tests. Test: Ran an app with backtrace enabled. Change-Id: I3246c48ae4f9811f64622d90d0a9b4d9d818702c
* Provide method to dump backtrace heap data.Christopher Ferris2017-09-051-0/+55
| | | | | | | | | | | | | For non-zygote spawned processes, we might want to dump the backtrace data. Provide a method to send a signal to a process and then dump the data to a file. Adds a method to dump the backtrace data on exit. Update documentation and explain format of heap dump data. Test: Ran unit tests, enabled new options and used them. Change-Id: Ie2fa706694160731afe02c1382b037d06df1d069
* Refactor Config from a struct to a class.Christopher Ferris2017-04-061-93/+139
| | | | | | | | | | | This should make it easier to add new options, and to add options that are complex. For example, I want to modify the behavior of record_allocs_file so that it also enables record_allocs to a default state. Test: All unit tests pass. Test: Enable the backtrace option and restart. Change-Id: Idf5cdeed06ade3bc2c8ae39d228734bf65209b4f
* Enable malloc debug using environment variablesTamas Berghammer2016-11-171-5/+2
| | | | | | | | | | | | | | | | | | Previously malloc debug can be enabled only using global settings accessible to the root user only. This CL adds a new option to enable it using environment variables making it possible to use it with pure native (shell) applications on production builds (from shell user) and prepares it for using it from logwrapper on production devices. Remove the old environment variable and property since they are not necessary. Test: Enable malloc debug using environment variable and verify Test: that it only affects the commands launched from the shell. Test: Enable malloc debug using the property variable and verify Test: that it affects all commands. Test: Run all unit tests in 32 bit and 64 bit. Change-Id: Iecb75a3471552f619f196ad550c5f41fcd9ce8e5
* Fix unittests broken by 545808aTamas Berghammer2016-09-071-1/+1
| | | | Change-Id: I590af5958e4dcb772b710be965ed6c99cd1d9234
* Add the record alloc option.Christopher Ferris2016-07-081-35/+94
| | | | | | | | | | | | This option adds the ability to record all of the allocation requests and dump them to a file when a signal is sent to the process. Included in this change, redo the option processing to add a new string option. Bug: 27747898 Change-Id: Ida043362e38b5eb1d459c99db9c2581015dab366
* Fix problem where unknown option is not an error.Christopher Ferris2016-03-141-0/+8
| | | | | | | | | If the first option is found, then any unknown options are simply ignored, but do not produce an error. Fixed this so that each option found is actually verified to exist. Bug: 27620263 Change-Id: If58732df3285eeae72188162c505e0e202fada8c
* Move hard-coded values to constants.Christopher Ferris2016-02-261-8/+9
| | | | | | | | Change all of the hard-coded config values to be defined constants. Also make sure to use these constants in the usage output. Bug: 26739265 Change-Id: I597a6d71279a2df9cc7e98c42ac70224261bac99
* Fix wrong guard values for 64 bit.Christopher Ferris2016-02-221-4/+8
| | | | | | | | | I added the code to force alignments of 8 for 32 bit and 16 for 64 bit, but I missed a couple of tests that failed due to this change. Fix the failing tests. Bug: 26739265 Change-Id: Ice9932d1419e59c07483c4c9fcdb84970844f0a6
* Fix the default alignment of the allocations.Christopher Ferris2016-02-121-0/+4
| | | | | | | | | | | | | | | | In order to enforce this constraint: The pointer returned if the allocation succeeds shall be suitably aligned so that it may be assigned to a pointer to any type of object and then used to access such an object in the space allocated. Force all allocations on 32 bit systems to have 8 byte alignment, and all allocations on 64 bit systems to have 16 byte alignment. Add a test to verify that the allocator returns the correct alignments. Bug: 26739265 Change-Id: I9af53279617408676b94e4ec6481b3ed7ffafc6a
* Add better free tracking.Christopher Ferris2016-01-291-1/+60
| | | | | | | | | | | | | | | | Included in this change: - Change the tag when a pointer is freed so it's easy to detect if an already freed pointer is being used. - Move the free backtrace out of the header. This backtrace is only used under only some circumstances, so no need to allocate space in all headers for it. - Add new option free_track_backtrace_num_frames to specify how many frames to record when the free occurs. This removes the dependency on the backtrace option to get backtraces. Bug: 26739265 Change-Id: I76f5209507dcf46af67ada162a7cb2bf282116f2
* Add min/max values for config values.Christopher Ferris2016-01-271-2/+174
| | | | | | | | This is to only allow realistic values for some of the options. Bug: 26739265 Change-Id: I172d5401c27e5d638d80f1c93c678c26c4dae0fc
* Malloc debug rewrite.Christopher Ferris2016-01-251-0/+380
The major components of the rewrite: - Completely remove the qemu shared library code. Nobody was using it and it appears to have broken at some point. - Adds the ability to enable/disable different options independently. - Adds a new option that can enable the backtrace on alloc/free when a process gets a specific signal. - Adds a new way to enable malloc debug. If a special property is set, and the process has an environment variable set, then debug malloc will be enabled. This allows something that might be a derivative of app_process to be started with an environment variable being enabled. - get_malloc_leak_info() used to return one element for each pointer that had the exact same backtrace. The new version returns information for every one of the pointers with same backtrace. It turns out ddms already automatically coalesces these, so the old method simply hid the fact that there where multiple pointers with the same amount of backtrace. - Moved all of the malloc debug specific code into the library. Nothing related to the malloc debug data structures remains in libc. - Removed the calls to the debug malloc cleanup routine. Instead, I added an atexit call with the debug malloc cleanup routine. This gets around most problems related to the timing of doing the cleanup. The new properties and environment variables: libc.debug.malloc.options Set by option name (such as "backtrace"). Setting this to a bad value will cause a usage statement to be printed to the log. libc.debug.malloc.program Same as before. If this is set, then only the program named will be launched with malloc debug enabled. This is not a complete match, but if any part of the property is in the program name, malloc debug is enabled. libc.debug.malloc.env_enabled If set, then malloc debug is only enabled if the running process has the environment variable LIBC_DEBUG_MALLOC_ENABLE set. Bug: 19145921 Change-Id: I7b0e58cc85cc6d4118173fe1f8627a391b64c0d7