<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8665">View Change</a></p><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>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, 83 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/65/8665/1</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..a568fe6<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,83 @@<br>+From 1ffa1dcff0126d9e3d9c783f981261eb32ff6d00 Mon Sep 17 00:00:00 2001<br>+From: George Joseph <gjoseph@digium.com><br>+Date: Sun, 25 Mar 2018 11:59:49 -0600<br>+Subject: [PATCH] os_core_unix: Set mutex = NULL in atomic destroy and add more<br>+ checks<br>+<br>+The pj_mutex functions all check for NULL mutexes but pj_atomic_destroy<br>+wasn't setting its mutex to NULL after it destroyed it so attempts<br>+to use the atomic again would cause a crash. This doesn't address<br>+why an apptempt was made to use the atomic again but it does prevent the<br>+crash.<br>+<br>+Also added a few other checks to the atomic functions.<br>+---<br>+ pjlib/src/pj/os_core_unix.c | 19 +++++++++++++++++--<br>+ 1 file changed, 17 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..085e4bd13 100644<br>+--- a/pjlib/src/pj/os_core_unix.c<br>++++ b/pjlib/src/pj/os_core_unix.c<br>+@@ -879,9 +879,15 @@ 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>+ #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 +898,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_RETURN(atomic_var, ; );<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 +958,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_RETURN(atomic_var, ; );<br>+ pj_atomic_inc_and_get(atomic_var);<br>+ }<br>+ <br>+@@ -974,6 +987,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_RETURN(atomic_var, ; );<br>+ pj_atomic_dec_and_get(atomic_var);<br>+ }<br>+ <br>+@@ -1005,6 +1019,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_RETURN(atomic_var, ; );<br>+ pj_atomic_add_and_get(atomic_var, value);<br>+ }<br>+ <br>+-- <br>+2.14.3<br>+<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8665">change 8665</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/8665"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Id25f70b79fdedf44ead6e6e1763a4417d3b3f825 </div>
<div style="display:none"> Gerrit-Change-Number: 8665 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>