Question on Stack overflow

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 I have a condition where in after running the project for say 30hrs or so the project execution goes wierd. I suspect a stack overflow because , when i do attach to ruuning terget and do step by step execution the program execution is not fine. It is not doing sequential execution of code. 

   

How to find out whether any stack overflow has occured or not and the reasons why stack overflow occurs?

0 Likes
6 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Easiest thing to do is setting a breakpoint on access near stack top. This will work only if you can connect a miniprog3 to your board.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Being a GNU novice this may be useless, but sounds like it may help

   

troubleshoot -

   

 

   

http://www.delorie.com/gnu/docs/gcc/gnat_ug_46.html

   

http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gnat_ugn_unw/Run_002dTime-Checks.html

   

http://en.wikipedia.org/wiki/Buffer_overflow_protection

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Go to debugger (using MiniProg3) and look at the Call stack window to make sure that if the program flow is proper or not.

0 Likes
Anonymous
Not applicable

 I can see in both Call stack and trying to do step by step execution , the way the program jumps from one point to other . What are the reasons for such a behaviour. What can cause my stack overflows - any function returns (because while building the project i saw "all functions do not return a value"), interrupts?????

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Nobody suggested to step through your program AFTER a stack-overflow has occured but to look at the stack BEFORE that happens. So the advise to set an access breakpoint near TOS

   

There are other chances to wreck a program:

   

Are there ANY warnings after a re-build? Get rid of each of them!

   

Are you using malloc() and free()? Set the pointer to NIL after a free.

   

Check each pointer befor usage for vadility.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 While stack overflow could be the problem, It can also be a software bug. and is easiy missed as the program works MOST of the time.

   

Here is an article that may help

   

http://www.embedded.com/electronics-blogs/other/4023329/Assert-Yourself

   

Also, if you can post your project, people here may be able to help as well.

0 Likes