<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8666">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  George Joseph: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjproject_bundled:  Add patch for pj_atomic crashes<br><br>There have been some crashes in the past where something attempts<br>to use a pj_atomic after it's already been destroyed.  This patch<br>tries to prevent it by making sure that pj_atomic_destroy sets<br>its mutex to NULL when it's done.  The pj_mutex functions already check<br>for a NULL mutex and just return PJ_EINVAL.<br><br>Teluu also added some checks to the win32 implementation as well.<br><br>Change-Id: Id25f70b79fdedf44ead6e6e1763a4417d3b3f825<br>---<br>A third-party/pjproject/patches/0070-os_core_unix-Set-mutex-NULL-in-atomic-destroy-and-ad.patch<br>1 file changed, 114 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/third-party/pjproject/patches/0070-os_core_unix-Set-mutex-NULL-in-atomic-destroy-and-ad.patch b/third-party/pjproject/patches/0070-os_core_unix-Set-mutex-NULL-in-atomic-destroy-and-ad.patch<br>new file mode 100644<br>index 0000000..3aafd69<br>--- /dev/null<br>+++ b/third-party/pjproject/patches/0070-os_core_unix-Set-mutex-NULL-in-atomic-destroy-and-ad.patch<br>@@ -0,0 +1,114 @@<br>+From 67485f3a6c711f67a40ff46288cb6be1658023bd Mon Sep 17 00:00:00 2001<br>+From: nanang <nanang@localhost><br>+Date: Mon, 26 Mar 2018 10:33:50 +0000<br>+Subject: [PATCH] Close #2101:  - set atomic's mutex to NULL in atomic destroy <br>+ - added few sanity checks to the atomic functions.<br>+<br>+---<br>+ pjlib/src/pj/os_core_unix.c  | 20 ++++++++++++++++++--<br>+ pjlib/src/pj/os_core_win32.c |  4 ++++<br>+ 2 files changed, 22 insertions(+), 2 deletions(-)<br>+<br>+diff --git a/pjlib/src/pj/os_core_unix.c b/pjlib/src/pj/os_core_unix.c<br>+index ebfe84348..c17ad4ef0 100644<br>+--- a/pjlib/src/pj/os_core_unix.c<br>++++ b/pjlib/src/pj/os_core_unix.c<br>+@@ -879,9 +879,16 @@ PJ_DEF(pj_status_t) pj_atomic_create( pj_pool_t *pool,<br>+  */<br>+ PJ_DEF(pj_status_t) pj_atomic_destroy( pj_atomic_t *atomic_var )<br>+ {<br>++    pj_status_t status;<br>++<br>+     PJ_ASSERT_RETURN(atomic_var, PJ_EINVAL);<br>++    <br>+ #if PJ_HAS_THREADS<br>+-    return pj_mutex_destroy( atomic_var->mutex );<br>++    status = pj_mutex_destroy( atomic_var->mutex );<br>++    if (status == PJ_SUCCESS) {<br>++        atomic_var->mutex = NULL;<br>++    }<br>++    return status;<br>+ #else<br>+     return 0;<br>+ #endif<br>+@@ -892,10 +899,16 @@ PJ_DEF(pj_status_t) pj_atomic_destroy( pj_atomic_t *atomic_var )<br>+  */<br>+ PJ_DEF(void) pj_atomic_set(pj_atomic_t *atomic_var, pj_atomic_value_t value)<br>+ {<br>++    pj_status_t status;<br>++<br>+     PJ_CHECK_STACK();<br>++    PJ_ASSERT_ON_FAIL(atomic_var, return);<br>+ <br>+ #if PJ_HAS_THREADS<br>+-    pj_mutex_lock( atomic_var->mutex );<br>++    status = pj_mutex_lock( atomic_var->mutex );<br>++    if (status != PJ_SUCCESS) {<br>++        return;<br>++    }<br>+ #endif<br>+     atomic_var->value = value;<br>+ #if PJ_HAS_THREADS<br>+@@ -946,6 +959,7 @@ PJ_DEF(pj_atomic_value_t) pj_atomic_inc_and_get(pj_atomic_t *atomic_var)<br>+  */<br>+ PJ_DEF(void) pj_atomic_inc(pj_atomic_t *atomic_var)<br>+ {<br>++    PJ_ASSERT_ON_FAIL(atomic_var, return);<br>+     pj_atomic_inc_and_get(atomic_var);<br>+ }<br>+ <br>+@@ -974,6 +988,7 @@ PJ_DEF(pj_atomic_value_t) pj_atomic_dec_and_get(pj_atomic_t *atomic_var)<br>+  */<br>+ PJ_DEF(void) pj_atomic_dec(pj_atomic_t *atomic_var)<br>+ {<br>++    PJ_ASSERT_ON_FAIL(atomic_var, return);<br>+     pj_atomic_dec_and_get(atomic_var);<br>+ }<br>+ <br>+@@ -1005,6 +1020,7 @@ PJ_DEF(pj_atomic_value_t) pj_atomic_add_and_get( pj_atomic_t *atomic_var,<br>+ PJ_DEF(void) pj_atomic_add( pj_atomic_t *atomic_var,<br>+                             pj_atomic_value_t value )<br>+ {<br>++    PJ_ASSERT_ON_FAIL(atomic_var, return);<br>+     pj_atomic_add_and_get(atomic_var, value);<br>+ }<br>+ <br>+diff --git a/pjlib/src/pj/os_core_win32.c b/pjlib/src/pj/os_core_win32.c<br>+index 1cb6004d3..8c934b34d 100644<br>+--- a/pjlib/src/pj/os_core_win32.c<br>++++ b/pjlib/src/pj/os_core_win32.c<br>+@@ -750,6 +750,7 @@ PJ_DEF(pj_status_t) pj_atomic_destroy( pj_atomic_t *var )<br>+ PJ_DEF(void) pj_atomic_set( pj_atomic_t *atomic_var, pj_atomic_value_t value)<br>+ {<br>+     PJ_CHECK_STACK();<br>++    PJ_ASSERT_ON_FAIL(atomic_var, return);<br>+ <br>+     InterlockedExchange(&atomic_var->value, value);<br>+ }<br>+@@ -784,6 +785,7 @@ PJ_DEF(pj_atomic_value_t) pj_atomic_inc_and_get(pj_atomic_t *atomic_var)<br>+  */<br>+ PJ_DEF(void) pj_atomic_inc(pj_atomic_t *atomic_var)<br>+ {<br>++    PJ_ASSERT_ON_FAIL(atomic_var, return);<br>+     pj_atomic_inc_and_get(atomic_var);<br>+ }<br>+ <br>+@@ -806,6 +808,7 @@ PJ_DEF(pj_atomic_value_t) pj_atomic_dec_and_get(pj_atomic_t *atomic_var)<br>+  */<br>+ PJ_DEF(void) pj_atomic_dec(pj_atomic_t *atomic_var)<br>+ {<br>++    PJ_ASSERT_ON_FAIL(atomic_var, return);<br>+     pj_atomic_dec_and_get(atomic_var);<br>+ }<br>+ <br>+@@ -815,6 +818,7 @@ PJ_DEF(void) pj_atomic_dec(pj_atomic_t *atomic_var)<br>+ PJ_DEF(void) pj_atomic_add( pj_atomic_t *atomic_var,<br>+                         pj_atomic_value_t value )<br>+ {<br>++    PJ_ASSERT_ON_FAIL(atomic_var, return);<br>+ #if defined(PJ_WIN32_WINNT) && PJ_WIN32_WINNT >= 0x0400<br>+     InterlockedExchangeAdd( &atomic_var->value, value );<br>+ #else<br>+-- <br>+2.14.3<br>+<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8666">change 8666</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/8666"/><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: merged </div>
<div style="display:none"> Gerrit-Change-Id: Id25f70b79fdedf44ead6e6e1763a4417d3b3f825 </div>
<div style="display:none"> Gerrit-Change-Number: 8666 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>