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.

Break on Stack Overflow in CCS with printf

Other Parts Discussed in Thread: MSP430F5510

For a seemingly unexplainable reason, every time my code finishes a printf, the debugger breaks when I have "Break on Stack Overflow" selected. At the break, the stack pointer SP is well within the range of the stack, so I don't really understand the reason for the break or if I need to be worried about my code.

I've filled the unused memory above the stack with known values (e.g., "DEAD BEEF") and do not see anything getting trampled on. For what it's worth, I'm running CCS 6.0.1 with an MSP430F5510.

What exactly is this break type looking for? Is there a problem with trying to use this breakpoint with C I/O or specifically printf?

  • Do you and the debugger agree about the size of the stack area?
    AFAIK, the debugger complains if the stack grows below 80% (or so) of the reserved stack size (which is a plain fictive value, as you cannot limit the stack). It simply sets a breakpoint on the stack pointer reaching below a certain address value.
    This mechanism completely fails on multithreading OS, where each thread has its own stack reserved on the heap.
    Also, having large local arrays in a function will send the stack pointer far into the heap, even if you never write to this area (and therefore never clobber the stack content).
    printf uses a lot of stack.

  • Hi, Jens.

    Thank you for your reply! Embarrassingly, I've discovered the answer. The "Break on Stack Overflow" breakpoint statically is set to the stack minimum (SP register <= &_stack) when the breakpoint is created. When I updated the stack size in the Linker Basic Options (I wanted to include stdio.h and use printf() and needed to increase the stack and heap sizes), my breakpoint was still looking for the original value.

  • I too had expected that the breakpoint gets updated when the ‘stack size setting’ is changed in the project. After all, the setting has no effect on the code at all, its only purpose is to trigger a linker error and guide the debugger.

**Attention** This is a public forum