[En-Nut-Discussion] Large auto variable called from main thread crashed programm

Philipp Burch phip at hb9etc.ch
Fri Jan 9 13:37:55 CET 2015

Hi Uwe!

On 09.01.2015 13:30, Uwe Bonnes wrote:
> Hello,
> I am working on a project with the STM32F411E, having 512 kByte of Flash and
> 128 kbyte of RAM. In a function called from the main thread, as soon as the
> size of a function local variable  gets from 512 to 1024 bytes, the program
> crashes. Static allocation of the variable lets the program work even with
> the bigger size.
> There is no other big RAM consumer.
> Any idea what could go wrong here?
> The debug backtrace isn't very helpfull.

Well, the most obvious thing would be an overflow of the main thread's
stack. Have you enabled the stack checking code to see how much is
actually used when you run it with the smaller variable?

Some other thing that comes to my mind is a stack-hungry interrupt
service routine. I'm still not sure which stack is actually used for
ISRs, but it may be the one used for the currently executing thread. So
if you have complex ISRs, that may cause some more random crashes.

Since the STM32 is also a Cortex-M3/4 processor, you could probably also
use the post-mortem stack checking code. It is an extension to Oles
Cortex debug macro and can be found in r5891 in the devnut_tiva branch.


More information about the En-Nut-Discussion mailing list