<p>Neels Hofmeyr <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/10636">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">lchan_fsm: lchan_fail_to(): store target state early<br><br>lchan_fail_to() is a macro to preserve useful source file:line information in<br>logging. But a side effect is that its target state argument might evaluate<br>differently at the end of the macro, if, say, the fi->state has changed.<br><br>I hit such an instance on timeout of WAIT_RLL_RTP_ESTABLISH:<br>lchan_fsm_timer_cb() calls macro lchan_fail(), which calls<br>lchan_fail_to(lchan_fsm_on_error[fi->state]). Unlike for normal function<br>invocation, this argument changes as fi->state changes. Since releasing the<br>lchan_rtp_fsm already transitions the lchan fi into WAIT_RF_RELEASE_ACK, the<br>final state change of lchan_fail_to() suddenly evaluates to the broken state<br>instead of the intended WAIT_RF_RELEASE_ACK.<br><br>Early in lchan_fail_to(), store the argument's value as of macro invocation.<br><br>Change-Id: Id9bf4580a112ee5629f553a8bcb6b5b03b1c5f53<br>---<br>M src/osmo-bsc/lchan_fsm.c<br>1 file changed, 3 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bsc/lchan_fsm.c b/src/osmo-bsc/lchan_fsm.c</span><br><span>index 9c22bde..e0015cb 100644</span><br><span>--- a/src/osmo-bsc/lchan_fsm.c</span><br><span>+++ b/src/osmo-bsc/lchan_fsm.c</span><br><span>@@ -211,9 +211,11 @@</span><br><span> </span><br><span> /* Set a failure message, trigger the common actions to take on failure, transition to a state to</span><br><span>  * continue with (using state timeouts from lchan_fsm_timeouts[]). Assumes local variable fi exists. */</span><br><span style="color: hsl(0, 100%, 40%);">-#define lchan_fail_to(state_chg, fmt, args...) do { \</span><br><span style="color: hsl(120, 100%, 40%);">+#define lchan_fail_to(STATE_CHG, fmt, args...) do { \</span><br><span>                 struct gsm_lchan *_lchan = fi->priv; \</span><br><span>            uint32_t state_was = fi->state; \</span><br><span style="color: hsl(120, 100%, 40%);">+          /* Snapshot the target state, in case the macro argument evaluates differently later */ \</span><br><span style="color: hsl(120, 100%, 40%);">+             const uint32_t state_chg = STATE_CHG; \</span><br><span>              lchan_set_last_error(_lchan, "lchan %s in state %s: " fmt, \</span><br><span>                                    _lchan->activate.concluded ? "failure" : "allocation failed", \</span><br><span>                               osmo_fsm_state_name(fi->fsm, state_was), ## args); \</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/10636">change 10636</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/10636"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bsc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Id9bf4580a112ee5629f553a8bcb6b5b03b1c5f53 </div>
<div style="display:none"> Gerrit-Change-Number: 10636 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>