• Home
  • History
  • Annotate
  • only in /bionic/libc/malloc_debug/
History log of /bionic/libc/malloc_debug/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
7a0224a66ba726f82c830c41e58ad910c9104f7a 21-Apr-2016 Christopher Ferris <cferris@google.com> Change pointer to allocation in unit tests.

I changed the output from "pointer" to "allocation" for allocation
mismatches. I forgot to update the tests.

Bug: 28218530

(cherry picked from commit 97fd7d95f5abd3fbc3274b2591883ecdd9cc03cc)

Change-Id: I4076e4ddb5d2385e786e3ebca187d1e84e3c172c
ests/malloc_debug_unit_tests.cpp
2b876a630720bc9eb2ec6b487882529c252a687b 18-Mar-2016 Christopher Ferris <cferris@google.com> Add malloc debug documentation.

Bug: 27902359
Bug: 28218530

(cherry picked from commit 713a8e36f863c27736ad4f29a5fd9bf84be83aaf)

Change-Id: I63c0cc53287d414ae6accd03c191f3474c02fc82
EADME.md
EADME_api.md
258abf70f93ee9231e46111f75cbedbc7cdf4ff9 15-Apr-2016 Christopher Ferris <cferris@google.com> Small fixes to malloc debug.

- Change the printed name from pointer to allocation to be explicit about
what is wrong.
- Change the signal to be SIGRTMAX - 19 instead of SIGRTMIN. This should
prevent problems if we have to reserve other real time signals.

Bug: 28218530

(cherry picked from commit ea26b33248663a836d2f0719cb4e46967b648fe2)

Change-Id: I707d5200c1804bdbf45fc46de0f2565016c48a82
onfig.cpp
reeTrackData.cpp
uardData.cpp
97fce67302a80bf282bff118cfa96936c5ad9e81 16-Mar-2016 Christopher Ferris <cferris@google.com> Fix race in malloc debug option free_track.

The free track mechanism could fail if, at the same time a free occurs,
another thread is trying to free and verify the same allocation. This
doesn't work if the freed allocation is added to the list and we still
do work on it. The fix is to only add to the free list when we are done
with the allocation.

Also fix a problem where the usable size is computed incorrectly because
two of the arguments where reversed.

In addition, add a check that the allocation being verified has the correct
tag before trying to check the body of the allocation.

Add a test to catch the original failure.

Add a test for the tag being different.

Bug: 27601650

(cherry picked from commit d0919623a2ef56107590eca9a9522a250fb8bd4a)

Change-Id: Ie1aa4d9a829da9a96de9b8bd1cc8fc681e9cab15
reeTrackData.cpp
alloc_debug.cpp
ests/malloc_debug_unit_tests.cpp
4451b53c3761b46fa33a3e47bfb0c62ca47e5fbb 14-Mar-2016 Christopher Ferris <cferris@google.com> Fix problem where unknown option is not an error.

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

(cherry picked from commit a4b14252752d14454afb48feb3272e8689e3a66d)

Change-Id: I709774456283879e2a8aa5ce375899eaa79f6bc3
onfig.cpp
ests/malloc_debug_config_tests.cpp
239838608dbe9917acddfe5a51d92350a4c8e135 10-Mar-2016 Colin Cross <ccross@android.com> malloc_debug: fix multiplication overflow in debug_calloc

The over flow check for nmemb * bytes in debug_calloc is incorrect,
use the builtin overflow functions to check for multiplication and
addition overflow.

Change-Id: I3f1c13102621bc5380be1f69caa88dba2118f3cb
alloc_debug.cpp
ests/malloc_debug_unit_tests.cpp
15af478080cfbfa800fb8172fdf70a84075925e3 10-Mar-2016 Colin Cross <ccross@android.com> malloc_debug: round 0 byte allocations up to 1 byte

0 byte allocations can cause problems if they are immediately followed
by another allocation with no header, as both allocations will have the
same address. Treat 0 byte allocations as 1 byte allocations so that
debug_iterate will return separate addresses for them.

Bug: 27578580
Change-Id: Ia8dc3481fa7062391e9b3ae58a36e8d47e7ee557
alloc_debug.cpp
b23c6606d2326f8835fc7fc35b23ff7ee5a48f48 10-Mar-2016 Colin Cross <ccross@android.com> malloc_debug: iterate: use usable_size

malloc_iterate with malloc debug enabled was returning allocation sizes
using the requested size instead of usable size. If anything wrote
pointers above the requested size but below the usable size, those
pointers would be invisible to libmemunreachable and referenced
allocations could be reported as a leak.

Bug: 27107100
Change-Id: I6b19fd631f68ce93b3aee408cc3d296ec457bd01
alloc_debug.cpp
598e2c0d2ae6b7fbc5eb470e4296c20ed1a011ee 23-Feb-2016 Christopher Ferris <cferris@google.com> Move hard-coded values to constants.

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

(cherry picked from commit 549e52200b6af3c33cba7ef759ea98b49fa40082)

Change-Id: I07b7095cad9c47207a31d9b95e4013f4cb07ae0e
onfig.cpp
ests/malloc_debug_config_tests.cpp
1724535fb4ebf6b6ff1b3ac06f7dcaf5cb36da78 20-Feb-2016 Christopher Ferris <cferris@google.com> Fix incorrect size of array.

When using sscanf and "%4s", the array passed in must include space for
a nul terminator.

Bug: 26739265

(cherry picked from commit f499dc91e774db4cb9d21f9a7c34704fa9b7ed39)

Change-Id: I8aac6fca3e5bc7a6399e2ed9c6ba4140a55ffdee
ndroid.mk
apData.cpp
b7ff533ed28f82c0981b83ae80e8bc8e3f350d0f 08-Feb-2016 Colin Cross <ccross@android.com> malloc_debug: reread /proc/pid/maps when entry is missing

Reread /proc/pid/maps on demand in case a new library has been loaded.

Bug: 27208635
(cherry picked from commit d75d4bea54a788dada3f2538a33cc491e4c56ed4)

Change-Id: I80140cf57fa3b3e93d51dbe7b7a27595b72ee694
apData.cpp
apData.h
acktrace.cpp
6deb3042df87f8569fb430dbf5f140f6a694ddfd 06-Feb-2016 Colin Cross <ccross@android.com> Add backtrace_string and export to libmemunreachable

Add backtrace_string to convert a malloc_debug backtrace to a string.
Also move the backtrace functions to libc_malloc_debug_backtrace so that
libmemunreachable can reuse them.

Bug: 27208635
(cherry picked from commit 2c75991359df165ca7cc7a6213fb227c0b5ed87c)

Change-Id: Ia93aaf010fbce1ace058439427066ea2dfd8bd13
ndroid.mk
apData.cpp
acktrace.cpp
acktrace.h
ebug_log.h
alloc_debug.cpp
d6c9b44091a8865a3b61ada247dd9abf4d6b8705 02-Feb-2016 Colin Cross <ccross@android.com> Export malloc_backtrace

Bug: 27208635
(cherry picked from commit 2d4721c0c57fe2f7c1e1b40df4763a561b3cf856)

Change-Id: Ida926cabb706dfd962b692ba1775da332f68488f
xported32.map
xported64.map
alloc_debug.cpp
c40577f740ae4f66cdba4b2137668fb3114bb99d 29-Jan-2016 Colin Cross <ccross@android.com> Export malloc_iterate and friends

Export malloc_iterate, malloc_enable, and malloc_disable to be used by
libmemunreachable.

Bug: 27208635
(cherry picked from commit 869691c6f7691dd5bf343617aa185c32e0d3d160)

Change-Id: Ifa44421a84ac3be6a57fac28c4da501febe88c28
rackData.cpp
rackData.h
xported32.map
xported64.map
alloc_debug.cpp
ests/malloc_debug_unit_tests.cpp
d863530eccceeae00c1c5d4968550a052f13ec2c 08-Feb-2016 Colin Cross <ccross@android.com> malloc_debug: reset TrackData mutex after fork

Add a pthread_atfork handler to malloc_debug to lock the TrackData mutex
during fork and reset it in the child. Ensures that the TrackData is
consistent when forking from a multi-threaded process, and that the
mutex is in a defined state in the child.

Bug: 27208635
(cherry picked from commit 7a28a3cf1f8df36e30724e8b4021cddde0596118)

Change-Id: I84bc67be09b8b767e1cf2f14141e2ae8dc4fb462
ebugData.cpp
ebugData.h
rackData.h
alloc_debug.cpp
a071f48b1f2088c4dd1a18dac58834e4488ac563 23-Feb-2016 Christopher Ferris <cferris@google.com> Fix wrong guard values for 64 bit.

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

(cherry picked from commit 0e2a0265798ed47cbbf6977f0f84cf81d93173a6)

Change-Id: I21c3e26a340df6e427f06625e525b88b19b0cae1
ests/malloc_debug_config_tests.cpp
39b952cf0a824db1cdc301dd048db0e56d4d5c24 12-Feb-2016 Christopher Ferris <cferris@google.com> Fix the default alignment of the allocations.

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

(cherry picked from commit 72df6708c829a4c6494936fdfbda6dc7e68e647b)

Change-Id: I44ca8bedb1dac375087da1af3a1d7d12034e037f
acktraceData.cpp
onfig.cpp
onfig.h
ebugData.cpp
uardData.cpp
alloc_debug.cpp
alloc_debug.h
ests/malloc_debug_config_tests.cpp
ests/malloc_debug_unit_tests.cpp
701bb65511aed14da6c51179619785e5706fa5a6 02-Feb-2016 Christopher Ferris <cferris@google.com> Remove the unused TrackHeader structure.

Change-Id: I07ae5de717e1fcfbe5dfe552a531db9f630da622
alloc_debug.h
ests/malloc_debug_unit_tests.cpp
7993b80f894db20af4d1d154221c42fea6171a3d 29-Jan-2016 Christopher Ferris <cferris@google.com> Add better free tracking.

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
acktraceData.cpp
acktraceData.h
onfig.cpp
onfig.h
ebugData.h
reeTrackData.cpp
reeTrackData.h
acktrace.cpp
acktrace.h
alloc_debug.cpp
alloc_debug.h
ests/backtrace_fake.cpp
ests/malloc_debug_config_tests.cpp
ests/malloc_debug_unit_tests.cpp
166c8535a5a4253bcb2b04bbd20a2a8c04c44f2c 28-Jan-2016 Christopher Ferris <cferris@google.com> Add min/max values for config values.

This is to only allow realistic values for some of the options.

Bug: 26739265

Change-Id: I172d5401c27e5d638d80f1c93c678c26c4dae0fc
onfig.cpp
ests/malloc_debug_config_tests.cpp
1e185a5056f85e281f699a92114b758591ae3b92 26-Jan-2016 Christopher Ferris <cferris@google.com> Fix gcc test issues.

Change-Id: I2b26b779f5198c7c9362a452b971260a8852aa7b
ndroid.mk
ests/malloc_debug_unit_tests.cpp
f2b67b85f5e192812212d3176c07e195c0ffa503 25-Jan-2016 Christopher Ferris <cferris@google.com> Fix build for gcc.

Gcc doesn't like the brace object initialization, so make all of
the Feature objects explicit.

Also, no arguments to the error_log macros make gcc unhappy, so add
an option to turn these into warnings. These will be fixed when we
add the explicit _error and _warn log functions.

Change-Id: I35af834dabb5548923e893dd980a751fdebfa13a
ndroid.mk
onfig.cpp
63860cb8fd1adf3f679b9b4ad876323a8d65cd9d 17-Nov-2015 Christopher Ferris <cferris@google.com> Malloc debug rewrite.

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
ndroid.mk
acktraceData.cpp
acktraceData.h
onfig.cpp
onfig.h
ebugData.cpp
ebugData.h
reeTrackData.cpp
reeTrackData.h
uardData.cpp
uardData.h
apData.cpp
apData.h
rackData.cpp
rackData.h
acktrace.cpp
acktrace.h
ebug_disable.cpp
ebug_disable.h
ebug_log.h
xported32.map
xported64.map
alloc_debug.cpp
alloc_debug.h
ests/backtrace_fake.cpp
ests/backtrace_fake.h
ests/libc_fake.cpp
ests/log_fake.cpp
ests/log_fake.h
ests/malloc_debug_config_tests.cpp
ests/malloc_debug_unit_tests.cpp
ests/property_fake.cpp