Add backtrace generation to MALLOC_DEBUG memory corruption reports

This patch allows astmm to access the backtrace generation code in Asterisk.
When memory is allocated, a backtrace is created and stored with the memory
region that tracks the allocation. If a memory corruption is detected, the
backtrace is printed to the astmm log. The backtrace will make use of the
BETTER_BACKTRACES build option if available.

As a result, this patch moves the backtrace generation code into its own file
and uses the non-wrapped versions of the C library memory allocation routines.
This allows the memory allocation code to safely use the backtrace generation
routines without infinitely recursing.

Review: https://reviewboard.asterisk.org/r/2567


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@391012 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Matthew Jordan
2013-06-08 22:09:07 +00:00
parent 2fe6b6a533
commit c43f380d03
8 changed files with 360 additions and 256 deletions

View File

@@ -525,7 +525,7 @@ int __ao2_ref_debug(void *user_data, int delta, const char *tag, const char *fil
struct astobj2 *obj = INTERNAL_OBJ(user_data);
if (obj == NULL) {
ast_backtrace();
ast_log_backtrace();
ast_assert(0);
return -1;
}