diff options
author | Richard Mudgett <rmudgett@digium.com> | 2013-08-23 18:07:40 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2013-08-23 18:07:40 +0000 |
commit | 46b9e5450fbd1af030812b1933e769c86baa4932 (patch) | |
tree | d489beee420ef5d34a873cab5c35ce9fcc23561a /include | |
parent | 32a0567c461ee426817e476724e206d603fe1e70 (diff) |
Fix memory corruption when trying to get "core show locks".
Review https://reviewboard.asterisk.org/r/2580/ tried to fix the mismatch
in memory pools but had a math error determining the buffer size and
didn't address other similar memory pool mismatches.
* Effectively reverted the previous patch to go in the same direction as
trunk for the returned memory pool of ast_bt_get_symbols().
* Fixed memory leak in ast_bt_get_symbols() when BETTER_BACKTRACES is
defined.
* Fixed some formatting in ast_bt_get_symbols().
* Fixed sig_pri.c freeing memory allocated by libpri when MALLOC_DEBUG is
enabled.
* Fixed __dump_backtrace() freeing memory from ast_bt_get_symbols() when
MALLOC_DEBUG is enabled.
* Moved __dump_backtrace() because of compile issues with the utils
directory.
(closes issue ASTERISK-22221)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2778/
........
Merged revisions 397525 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 397528 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397570 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/astmm.h | 6 | ||||
-rw-r--r-- | include/asterisk/backtrace.h | 2 | ||||
-rw-r--r-- | include/asterisk/lock.h | 16 | ||||
-rw-r--r-- | include/asterisk/utils.h | 16 |
4 files changed, 13 insertions, 27 deletions
diff --git a/include/asterisk/astmm.h b/include/asterisk/astmm.h index c2a717550..1b008120a 100644 --- a/include/asterisk/astmm.h +++ b/include/asterisk/astmm.h @@ -54,6 +54,12 @@ extern "C" { #undef vasprintf #undef free +void *ast_std_malloc(size_t size); +void *ast_std_calloc(size_t nmemb, size_t size); +void *ast_std_realloc(void *ptr, size_t size); +void ast_std_free(void *ptr); +void ast_free_ptr(void *ptr); + void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func); void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func); void *__ast_malloc(size_t size, const char *file, int lineno, const char *func); diff --git a/include/asterisk/backtrace.h b/include/asterisk/backtrace.h index fef1d86fa..95358bfd2 100644 --- a/include/asterisk/backtrace.h +++ b/include/asterisk/backtrace.h @@ -87,7 +87,7 @@ void *__ast_bt_destroy(struct ast_bt *bt); * \param addresses A list of addresses, such as the ->addresses structure element of struct ast_bt. * \param num_frames Number of addresses in the addresses list * \retval NULL Unable to allocate memory - * \return List of strings. This should be freed with a single call to free. + * \return List of strings. Free the entire list with a single ast_std_free call. * \since 1.6.2.16 */ char **__ast_bt_get_symbols(void **addresses, size_t num_frames); diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h index 34e944476..aee084f32 100644 --- a/include/asterisk/lock.h +++ b/include/asterisk/lock.h @@ -290,22 +290,6 @@ void ast_remove_lock_info(void *lock_addr); #endif /* HAVE_BKTR */ #endif /* !defined(LOW_MEMORY) */ -#ifdef HAVE_BKTR -static inline void __dump_backtrace(struct ast_bt *bt, int canlog) -{ - char **strings; - - ssize_t i; - - strings = backtrace_symbols(bt->addresses, bt->num_frames); - - for (i = 0; i < bt->num_frames; i++) - __ast_mutex_logger("%s\n", strings[i]); - - free(strings); -} -#endif - /*! * \brief log info for the current lock with ast_log(). * diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index 1623775b9..e24dc02d8 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -465,24 +465,20 @@ long int ast_random(void); */ #define ast_random_double() (((double)ast_random()) / RAND_MAX) +#ifndef __AST_DEBUG_MALLOC +#define ast_std_malloc malloc +#define ast_std_calloc calloc +#define ast_std_realloc realloc +#define ast_std_free free + /*! * \brief free() wrapper * * ast_free_ptr should be used when a function pointer for free() needs to be passed * as the argument to a function. Otherwise, astmm will cause seg faults. */ -#ifdef __AST_DEBUG_MALLOC -static void ast_free_ptr(void *ptr) attribute_unused; -static void ast_free_ptr(void *ptr) -{ - ast_free(ptr); -} -#else #define ast_free free #define ast_free_ptr ast_free -#endif - -#ifndef __AST_DEBUG_MALLOC /* * This buffer is in static memory. We never intend to read it, |