This is my first step to blogging world, where words matter and quality counts. I was befuddled while searching for my first blog topic. For last one month I was working on PIC 16F877 faced some challenges which i was not aware of. So finalized that I’m going to write on issues I faced. In this blog would like to start with stack-overflow in embedded-systems. First of all, I gone through Wikipedia description of stack overflow. There’s nothing wrong with the description – it’s just incomplete from an embedded systems perspective. So decided to investigate on that and start a blog.
What’s your stack size set to?
Which stack is overflowing?
Reasons
- An interrupt service routine can use up a huge amount of space on the stack. This problem is arise if your system allows interrupts to be nested (that is, it allows an ISR to itself be interrupted).
- Certain library functions (like printf and companions) can use an enormous amount of stack space.
- Calling functions in nested manner, going beyond your stack size.
- If you are writing partially in assembly language, and you failing to pop every register that you pushed? This often occurs if you have more than one exit point from a function or ISR.
- If you are writing entirely in assembly language, and you are not setting up the stack pointer correctly, and you don’t know which way the stack grows?
- Have you made the mistake of programming a micro-controller that you don’t understand? For example, low end PIC processors have a tiny call stack which is easily overflowed. If you are programming a PIC and don’t know about this limitation, then I’m not surprised you are having problems.