cancel
Showing results for 
Search instead for 
Did you mean: 

Infinite loop in stm32_list.c

JFisher-Legato
Associate III

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:

JFisherLegato_0-1766354385493.png

And following the logic through of the passPendingToActive() it seems like we'll never recover from this. The application becomes unresponsive.

Some relevant details:

  • Our application is running in ThreadX
  • We are abusing the BLE thread (HCI Async Event Task) currently (doing a Flash Erase) - this obviously will be moved off into an application thread, but currently it is in the BLE thread:
    JFisherLegato_0-1766410981989.png

     

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

2 REPLIES 2
TDK
Super User

Set a hardware watchpoint to figure out when and where the list gets modified with a link to itself.

If you feel a post has answered your question, please click "Accept as Solution".

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.