This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Very odd behaviour, stack overflow?

Hi folks,

I have a F28027 project running in debug with some variables in the expressions window, some of which are only ever changed from the expressions window and never changed in code, only read.

If I run the program then after some time expires, the variables in the expressions window start to change in random and unexpected manner, including those that should never be written to by the program.

Pausing the program and viewing the disassembly shows operation to be in the reserved memory space between 0x009000 and 0x3D7800. 

I thought maybe there has been stack overflow, so add hardware watchpoint at __STACK_END - 2. Now execution breaks somewhere inside IQatan2Table (~0x3FE903), though the IQtan function is never, directly, called from the code. Also SP now holds 0x035B, which is 13 more than __STACK_END-2 and the memory browser also shows changes to data corresponding to this (see image).

This definitely seems to me to be stack overflow, but is this caused by execution somehow branching to an incorrect point (e.g. IQtan2table) or is this branching an effect of the stack overflow?

If stack overflow is the root cause, what is the best way to track down what is causing this to occur??

Thanks

P.S. If I allow the program to continue to run, it doesn't crash or reach ISR_ILLEGAL, it just keeps running off through reserved memory.

  • Mr. Mole,

    Stack overflow might be the cause, or it might be a symptom.  I would start by commenting out half of your program, and see if it runs ok.  If it does, then add back in half of what you commented out, etc.  Divide and conquer.  The tough thing about low-level programming is that one single bad pointer can destroy the whole system.

    Regards,

    Bill