diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2023-03-30 23:51:55 +0200 |
---|---|---|
committer | Keith Whyte <keith@rhizomatica.org> | 2024-04-01 02:36:14 +0100 |
commit | 6c6ca4450a59aa5c3c36107f11c28379dfac4d2a (patch) | |
tree | 18d590604be8fd7a1fdb00970ff86b7a23a481e8 | |
parent | b8c92f7fa9ac7e7e00f53089e64c924fe7a2a7f9 (diff) |
attempt to catch a segfault: lchan pointing at stale conn
Change-Id: I47655da40a913d85d5bb5240a5e0ed95173f156e
-rw-r--r-- | src/osmo-bsc/bsc_subscr_conn_fsm.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/osmo-bsc/bsc_subscr_conn_fsm.c b/src/osmo-bsc/bsc_subscr_conn_fsm.c index f1f48bc35..c17338a5e 100644 --- a/src/osmo-bsc/bsc_subscr_conn_fsm.c +++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c @@ -1129,6 +1129,38 @@ static void gscon_fsm_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *d } } +/* Sanity check / debug shim to catch cleanup failures: iterate all lchans and make sure none are still pointing at this + * conn. */ +static void ensure_conn_unused(struct gsm_subscriber_connection *conn) +{ + struct gsm_bts *bts; + struct gsm_network *network = bsc_gsmnet; + + llist_for_each_entry(bts, &network->bts_list, list) { + struct gsm_bts_trx *trx; + + llist_for_each_entry(trx, &bts->trx_list, list) { + int i; + for (i = 0; i < ARRAY_SIZE(trx->ts); i++) { + struct gsm_bts_trx_ts *ts = &trx->ts[i]; + struct gsm_lchan *lchan; + + ts_for_n_lchans(lchan, ts, ts->max_lchans_possible) { + if (lchan->conn == conn) { + LOG_LCHAN(lchan, LOGL_ERROR, + "This lchan still points at discarded conn %s\n", + osmo_fsm_inst_name(conn->fi)); + LOGPFSML(conn->fi, LOGL_ERROR, + "This conn is discarding, but lchan is still pointing at this conn: %s\n", + lchan->name); + lchan->conn = NULL; + } + } + } + } + } +} + static void gscon_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause) { struct gsm_subscriber_connection *conn = fi->priv; @@ -1159,6 +1191,8 @@ static void gscon_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cau conn->bsub = NULL; } + ensure_conn_unused(conn); + llist_del(&conn->entry); talloc_free(conn); } |