History log of /bionic/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
Revision Date Author Comments
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
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
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
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
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
701bb65511aed14da6c51179619785e5706fa5a6 02-Feb-2016 Christopher Ferris <cferris@google.com> Remove the unused TrackHeader structure.

Change-Id: I07ae5de717e1fcfbe5dfe552a531db9f630da622
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
1e185a5056f85e281f699a92114b758591ae3b92 26-Jan-2016 Christopher Ferris <cferris@google.com> Fix gcc test issues.

Change-Id: I2b26b779f5198c7c9362a452b971260a8852aa7b
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