ESP8266 crashes when compiled in Debug mode
Applies to all revisions before 6.16
You use PlatformIO, and your program works correctly when compiled in “release” mode.
However, when you compile with the “debug” mode, the ESP8266 behaves weirdly or crashes with
This is a known issue due to a stack overflow in the recursive part of
Indeed, when compiled with the flag
-Og (the default when you build in “debug” mode), the stack usage in
deserializeJson() is multiplied by five.
To fix this issue, upgrade to ArduinoJson 6.16 or above.
As an alternative, you can also change the
Instead of the default
-Og -g2 -ggdb2, use
-O0 -g2 -ggdb2.
; platformio.ini build_type = debug debug_build_flags = -O0 -g2 -ggdb2
-O0 disables all optimization; it used to be the recommended flag before GCC 4.8 introduced