Skip to main content
NMuth
Associate
December 1, 2018
Question

How to Detect the Stack Overflow in the STM32F207Vgt

  • December 1, 2018
  • 4 replies
  • 1253 views

I am using Stm32f207....i am Suspecting there is stack overflow happening in my code.how to Check it actually?

    This topic has been closed for replies.

    4 replies

    waclawek.jan
    Super User
    December 1, 2018

    Although not entirely reliable, the easiest method is to fill the memory with a easily recognizable pattern, run the program and observe in the debugger how far the stack has reached.

    A more rigorous method is a static analysis, but that needs to have support from the toolchain, and also it gets complicated as soon as indirect calls (known as function pointers) are called, and/or stack usage changes dynamically e.g when using alloca().

    RTOS pose a whole new group of problems in this regard.

    JW

    NMuth
    NMuthAuthor
    Associate
    December 1, 2018

    is there any Memory Mapping we can use t check it?

    Tesla DeLorean
    Guru
    December 1, 2018

    You can have your own code check how much of the pattern remains in memory.

    You could put the stack at the bottom of memory so it hard faults as you drive it through the floor.​

    You might be able to use the MPU settings to Mem Fault in a similar manner. Review the chip TRM.​

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    waclawek.jan
    Super User
    December 1, 2018

    I don't know what do you mean by Memory Mapping.

    JW