History log of /bionic/libc/malloc_debug/backtrace.cpp
Revision Date Author Comments
c0f1f552f9a4ddba7df737a5ea6696fac6a678ea 15-Nov-2016 Christopher Ferris <cferris@google.com> Fix uninitialized variable usage.

If the dladdr call fails, then info.dli_fname will be unitialized.
Make sure that this can't happen.

Bug: 32907235

Test: Enabled malloc debug on an angler and verified that function names
Test: still work.
Change-Id: I738e66d9f37bce07bc4c10f1f9bac11fbfdae2c7
(cherry picked from commit a19bc2d4edfc261bdccfc5f855c50e83477b3757)
(cherry picked from commit b7f0267f0ddfa2d2ffb71a7980e80b05961401d0)
b7f0267f0ddfa2d2ffb71a7980e80b05961401d0 15-Nov-2016 Christopher Ferris <cferris@google.com> Fix uninitialized variable usage.

If the dladdr call fails, then info.dli_fname will be unitialized.
Make sure that this can't happen.

Bug: 32907235

Test: Enabled malloc debug on an angler and verified that function names
Test: still work.
Change-Id: I738e66d9f37bce07bc4c10f1f9bac11fbfdae2c7
(cherry picked from commit a19bc2d4edfc261bdccfc5f855c50e83477b3757)
a19bc2d4edfc261bdccfc5f855c50e83477b3757 15-Nov-2016 Christopher Ferris <cferris@google.com> Fix uninitialized variable usage.

If the dladdr call fails, then info.dli_fname will be unitialized.
Make sure that this can't happen.

Bug: 32907235

Test: Enabled malloc debug on an angler and verified that function names
Test: still work.
Change-Id: I738e66d9f37bce07bc4c10f1f9bac11fbfdae2c7
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
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
d75d4bea54a788dada3f2538a33cc491e4c56ed4 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.

Change-Id: Iac8109b3e6a07bf02c38300b21eecabf4bcd54df
2c75991359df165ca7cc7a6213fb227c0b5ed87c 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.

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