[asterisk-dev] [Code Review] 2580: Consistent memory allocation by ast_bt_get_symbols

wdoekes reviewboard at asterisk.org
Tue Aug 6 07:03:07 CDT 2013



> On June 1, 2013, 1:50 a.m., Russell Bryant wrote:
> > Soo ... why is this necessary?
> 
> wdoekes wrote:
>     Because it's broken? When
>     
>     [X] MALLOC_DEBUG
>     [X] BETTER_BACKTRACES
>     
>     memory was allocated with ast_calloc() and free'd with free(). 
>     
>     If !MALLOC_DEBUG then ast_free==free, and if !BETTER_BACKTRACES then the memory was allocated with regular malloc().
>     
>     I see now that https://reviewboard.asterisk.org/r/2567/diff/ does the inverse, and replaces the ast_calloc() calls with calloc() instead. That works too.
> 
> Matt Jordan wrote:
>     My patch on r2567 was geared only for trunk, so I don't want to much with the MALLOC_DEBUG code in release branches unless we really, really need it. It'd be easy to backport that change for a release branch if someone really wanted it anyway.
>     
>     So, if this patch goes into 1.8, we can always block it at 11.
>     
>     For the patch on r2567, I obviously needed to go with the unadorned memory allocation calls to use the backtrace code in astmm.c. In that case, we could still marshal the memory over to ast_* calls in other places like you've done, which is at least more consistent with the memory tracking code.
>     
>     I'm good with however we want to do this.

Ok. Shall I put it in and block it after 11?


- wdoekes


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/2580/#review8752
-----------------------------------------------------------


On May 31, 2013, 8:43 a.m., wdoekes wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/2580/
> -----------------------------------------------------------
> 
> (Updated May 31, 2013, 8:43 a.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> ast_bt_get_symbols can return either an ast_malloc'd or a regular malloc'd list, depending on the value of BETTER_BACKTRACES.
> 
> The result was always free'd (not ast_free'd).
> 
> This patch:
>  - copies the malloc'd list from backtrace_symbols into ast_malloc'd memory,
>  - replaces the free's with ast_free's,
>  - documents that the ast_bt_get_symbols return value should be freed.
> 
> Unsure whether to put it in 1.8, since ast_bt_get_symbols() might be used by an external module.
> 
> 
> Diffs
> -----
> 
>   /trunk/main/utils.c 390180 
>   /trunk/main/logger.c 390180 
>   /trunk/main/astobj2.c 390180 
>   /trunk/include/asterisk/logger.h 390180 
> 
> Diff: https://reviewboard.asterisk.org/r/2580/diff/
> 
> 
> Testing
> -------
> 
> Compile tested only.
> 
> 
> Thanks,
> 
> wdoekes
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20130806/10d0f1d0/attachment.htm>


More information about the asterisk-dev mailing list