2025-12-22 5:43 AM
Hello,
I'm having trouble with our BLE app where our code gets stuck in an infinite loop in `stm_list.c`, specifically in the `passPendingToActive()` function.
When I expand the `AmmPendingCallback` variable in CubeIDE, I see this:
And following the logic through of the passPendingToActive() it seems like we'll never recover from this. The application becomes unresponsive.
Some relevant details:
I suspect the fact that we're abusing the BLE thread is what's causing this, but in any case it seems like incorrect behavior. The LST_is_empty (&AmmPendingCallback) check is never TRUE, so the while loop never exits.
Any thoughts on what could be causing this?
Cheers,
Jonathan
2025-12-22 6:03 AM
Set a hardware watchpoint to figure out when and where the list gets modified with a link to itself.
2025-12-22 7:56 AM
What's interesting is it seems like it's not a one-step loop -- it's more like A -> B -> A -> ... (see image above). I'm not exactly sure what to check with the hardware watchpoint. Here's the contents of passPendingToActive():
void passPendingToActive (void)
{
AMM_VirtualMemoryCallbackFunction_t * p_TmpElt = NULL;
while (LST_is_empty (&AmmPendingCallback) == FALSE)
{
/* Remove the head element */
LST_remove_head (&AmmPendingCallback, (tListNode**)&p_TmpElt);
/* Add at the bottom */
LST_insert_tail(&AmmActiveCallback, (tListNode *)p_TmpElt);
}
}I put a breakpoint in pushPending() while stuck in this loop, and that never halted. That's what makes me suspect a logic error someplace.