<p>Richard Mudgett <strong>posted comments</strong> on this change.</p><p><a href="https://gerrit.asterisk.org/8521">View Change</a></p><p>Patch set 4:<span style="border-radius: 3px; display: inline-block; margin: 0 2px; padding: 4px;background-color: #ffd4d4;">Code-Review -1</span></p><p>(8 comments)</p><ul style="list-style: none; padding-left: 20px;"><li><p><a href="https://gerrit.asterisk.org/#/c/8521/4/include/asterisk/astmm.h">File include/asterisk/astmm.h:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/8521/4/include/asterisk/astmm.h@133">Patch Set #4, Line 133:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">#define calloc(a, b) \<br>      __ast_calloc(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br>#define malloc(a) \<br>      __ast_malloc(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br>#define free(a) \<br>   __ast_free(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br>#define realloc(a, b) \<br>       __ast_realloc(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br>#define strdup(a) \<br>     __ast_strdup(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br>#define strndup(a, b) \<br>     __ast_strndup(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br>#define asprintf(a, b, c...) \<br>  __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)<br>#define vasprintf(a, b, c) \<br>        __ast_vasprintf(a, b, c, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">These should be calling the repl versions.  (Except for __ast_free().</p></li></ul></li><li><p><a href="https://gerrit.asterisk.org/#/c/8521/4/main/astmm.c">File main/astmm.c:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/8521/4/main/astmm.c@36">Patch Set #4, Line 36:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">/* These functions are not used from anyplace else in Asterisk but are exposed for the<br> * bundled pjproject.  They are not static functions so prototype declarations need to<br> * be visible from this source. */<br>void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc;<br>void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *func) attribute_malloc;<br>void *__ast_repl_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func);<br>char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func) attribute_malloc;<br>char *__ast_repl_strndup(const char *s, size_t n, const char *file, int lineno, const char *func) attribute_malloc;<br>int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)<br> __attribute__((format(printf, 5, 6)));<br>int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)<br> __attribute__((format(printf, 2, 0)));<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">These need to be moved to astmm.h so redirected stdlib versions go to the MALLOC_DEBUG replacements.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/8521/4/main/astmm.c@522">Patch Set #4, Line 522:</a> <code style="font-family:monospace,monospace">  DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This is in __ast_alloc_region().</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/8521/4/main/astmm.c@1572">Patch Set #4, Line 1572:</a> <code style="font-family:monospace,monospace">void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">We need to keep __ast_repl_calloc_cache().  However, we can make the two __ast_repl_calloc_cache() versions static functions.  As currently coded, DEBUG_CHAOS returning will not get the MALLOC_FAILURE_MSG if it decides to randomly fail the allocation.</p><p style="white-space: pre-wrap; word-wrap: break-word;">We need the __ast_calloc_cache() to do just like __ast_calloc() but call __ast_repl_calloc_cache() instead.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/8521/4/main/astmm.c@1629">Patch Set #4, Line 1629:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">        if (res < 0) {<br>             /*<br>             * *strp is undefined so set to NULL to ensure it is<br>           * initialized to something useful.<br>            */<br>           *strp = NULL;<br> }<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">This should be removed as it is not done by the stdlib.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/8521/4/main/astmm.c@1648">Patch Set #4, Line 1648:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">     if (res < 0) {<br>             /*<br>             * *strp is undefined so set to NULL to ensure it is<br>           * initialized to something useful.<br>            */<br>           *strp = NULL;<br> }<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">This should go in the __ast_vasprintf as it is not done by the stdlib.</p></li></ul></li><li><p><a href="https://gerrit.asterisk.org/#/c/8521/4/third-party/pjproject/patches/asterisk_malloc_debug.h">File third-party/pjproject/patches/asterisk_malloc_debug.h:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/8521/4/third-party/pjproject/patches/asterisk_malloc_debug.h@28">Patch Set #4, Line 28:</a> <code style="font-family:monospace,monospace">int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This file needs to be reverted and then the attribute_malloc added where appropriate.</p></li></ul></li><li><p><a href="https://gerrit.asterisk.org/#/c/8521/4/third-party/pjproject/patches/asterisk_malloc_debug.c">File third-party/pjproject/patches/asterisk_malloc_debug.c:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/8521/4/third-party/pjproject/patches/asterisk_malloc_debug.c@25">Patch Set #4, Line 25:</a> <code style="font-family:monospace,monospace">int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This file needs to be reverted.</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/8521">change 8521</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8521"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: If9df4377f74bdbb627461b27a473123e05525887 </div>
<div style="display:none"> Gerrit-Change-Number: 8521 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Thu, 15 Mar 2018 00:51:31 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>