When access_model_subscription_list_dealloc() is called the entry is memset to 0 and the ACCESS_INTERNAL_STATE_INVALIDATED flag is set.
The function access_model_subscription_list_alloc() will allocate entries from m_subscription_list_pool which haven't got the ACCESS_INTERNAL_STATE_ALLOCATED flag set, thus it can reuse entries that has previously been de-alloced with the ACCESS_INTERNAL_STATE_INVALIDATED flag set.
The end result is that the allocated subscription list will be invalidated and removed from flash on every boot. (Or actually crash, see the related issue)
The following patch ensure that the ACCESS_INTERNAL_STATE_INVALIDATED flag is cleared during alloc. One could consider doing a memset(0) instead.
diff --git a/mesh/access/src/access.c b/mesh/access/src/access.c index 66e3d82..332e579 100644 --- a/mesh/access/src/access.c +++ b/mesh/access/src/access.c @@ -1407,6 +1407,7 @@ uint32_t access_model_subscription_list_alloc(access_model_handle_t handle) { if (!ACCESS_INTERNAL_STATE_IS_ALLOCATED(m_subscription_list_pool[i].internal_state)) { + ACCESS_INTERNAL_STATE_INVALIDATED_CLR(m_subscription_list_pool[i].internal_state); ACCESS_INTERNAL_STATE_ALLOCATED_SET(m_subscription_list_pool[i].internal_state); m_model_pool[handle].model_info.subscription_pool_index = i; sublist_store(i);
This is likely related to https://devzone.nordicsemi.com/f/nordic-q-a/56494/access_model_subscription_list_dealloc-causes-assert-with-mesh-sdk-4-0-0