PlatformIO Community

Why irregular stackOverFlow?

Error message:
108. HighWater: 193
109. HighWater: 193
ERROR A stack overflow in task Some Task has been detected.
abort() was called at PC 0x400887d0 on core 0

In a program with only one task the stackOverFlow kick’s in at irregular intervals.
I observed SO at: 0, [109, 193], [412, 193], etc.
109 and 412 being the number of iterations; 193 the highWaterMark.

StackSize is 1024. I read somewhere: “stackOverFlow kick’s in when 20 bytes (not words) before stack limit is reached”.

StackSize - waterMark = wordsUsed
1024 - 200 = 824

So, there seems to be plenty of stack, still it overflows at irregular intervals; what is going on?