<p>pespin has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-pcu/+/22178">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Workaround ASan false positive runtime errors under some platforms<br><br>Under some platforms (RPI4, ARM) container older ASan, it will log false<br>positive log errors which will make unit test fail because then output<br>changes:<br>"""<br>pcu_l1_if.cpp:847:2: runtime error: member access within misaligned address 0xb3f0b78c for type 'struct GprsMs', which requires 8 byte alignment<br>"""<br><br>The pointer is indeed misaligned, but it's not actually a bug, because<br>the pointer is never derreferenced. That happens during<br>llist_for_each_entry operation where it does cast the pointer but it<br>only checks if the list has actually reached the end.<br><br>To workaround the issue, simply defer casting it by using llist_for_each<br>instead, where the pointer is assigned only in the case it really points<br>to a GprsMS struct.<br><br>Change-Id: I149fb42706501eb33f9c6fe48f76a03ddee5954a<br>---<br>M src/pcu_l1_if.cpp<br>M src/pcu_vty_functions.cpp<br>2 files changed, 7 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/78/22178/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp</span><br><span>index 9cc6270..2aea00b 100644</span><br><span>--- a/src/pcu_l1_if.cpp</span><br><span>+++ b/src/pcu_l1_if.cpp</span><br><span>@@ -840,15 +840,16 @@</span><br><span> </span><br><span> static int pcu_rx_app_info_req(struct gsm_pcu_if_app_info_req *app_info_req)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-  GprsMs *ms;</span><br><span>  BTS *bts = BTS::main_bts();</span><br><span>  struct gprs_rlcmac_bts *bts_data = bts->bts_data();</span><br><span style="color: hsl(120, 100%, 40%);">+        struct llist_head *tmp;</span><br><span> </span><br><span>  LOGP(DL1IF, LOGL_DEBUG, "Application Information Request received: type=0x%08x len=%i\n",</span><br><span>       app_info_req->application_type, app_info_req->len);</span><br><span> </span><br><span>   bts_data->app_info_pending = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-      llist_for_each_entry(ms, bts->ms_store().ms_list(), list) {</span><br><span style="color: hsl(120, 100%, 40%);">+        llist_for_each(tmp, bts->ms_store().ms_list()) {</span><br><span style="color: hsl(120, 100%, 40%);">+           GprsMs *ms = llist_entry(tmp, typeof(*ms), list);</span><br><span>            if (!ms_dl_tbf(ms))</span><br><span>                  continue;</span><br><span>            bts_data->app_info_pending++;</span><br><span>diff --git a/src/pcu_vty_functions.cpp b/src/pcu_vty_functions.cpp</span><br><span>index 92be77b..0276b3e 100644</span><br><span>--- a/src/pcu_vty_functions.cpp</span><br><span>+++ b/src/pcu_vty_functions.cpp</span><br><span>@@ -207,10 +207,12 @@</span><br><span> int pcu_vty_show_ms_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data)</span><br><span> {</span><br><span>         BTS *bts = bts_data->bts;</span><br><span style="color: hsl(0, 100%, 40%);">-    GprsMs *ms_iter;</span><br><span style="color: hsl(120, 100%, 40%);">+      struct llist_head *tmp;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-     llist_for_each_entry(ms_iter, bts->ms_store().ms_list(), list)</span><br><span style="color: hsl(120, 100%, 40%);">+     llist_for_each(tmp, bts->ms_store().ms_list()) {</span><br><span style="color: hsl(120, 100%, 40%);">+           GprsMs *ms_iter = llist_entry(tmp, typeof(*ms_iter), list);</span><br><span>          show_ms(vty, ms_iter);</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span> </span><br><span>        return CMD_SUCCESS;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-pcu/+/22178">change 22178</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.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.osmocom.org/c/osmo-pcu/+/22178"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I149fb42706501eb33f9c6fe48f76a03ddee5954a </div>
<div style="display:none"> Gerrit-Change-Number: 22178 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>