Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.
Crash · stack overflow

Fix “Stack canary watchpoint triggered (loopTask)”

A task used more stack than it was given. Large local arrays, deep recursion or big String objects in loop() are the usual causes.

ESP32ESP32-S3Updated 31 Oct 2026

Community draft — report a mistake

What you see

OutputOutput
Guru Meditation Error: Core  1 panic'ed (Unhandled debug exception).
Debug exception reason: Stack canary watchpoint triggered (loopTask)
Core  1 register dump:
PC      : 0x40088c7d  PS      : 0x00060736  A0      : 0x800d3a0c  A1      : 0x3ffb0e40
...
Backtrace: 0x40088c7a:0x3ffb0e40 0x400d3a09:0x3ffb0f60 0x400d1b2f:0x3ffb1f80

Rebooting...

Every FreeRTOS task gets a fixed-size stack. This crash means your code (named in brackets — here loopTask, the Arduino loop) used all of it. The fix is to use less stack, not to ignore the error.

Quick fix — try in order

  1. 1

    Move big arrays out of functions

    A local array like uint8_t buf[8192] inside loop() lives on the stack. Make it static or global, or allocate it on the heap.

  2. 2

    Avoid deep recursion

    Each recursive call uses more stack; rewrite it as a loop.

  3. 3

    Give your own tasks more stack

    In xTaskCreate, increase the stack size argument (in bytes on ESP32) — try 4096 → 8192.

  4. 4

    Decode the backtrace

    It shows which function was using the stack when the canary was hit.

Why it happens

What is the canary?

FreeRTOS places a guard pattern at the end of each task’s stack and watches it. If code writes into it, the stack has overflowed and the chip stops before memory is corrupted further.

loopTask stack size

Arduino’s loop() runs in a task with about 8 KB of stack. Large buffers, JSON documents and long String chains inside loop() can exceed that.

Libraries with big buffers

Some HTTPS, JSON or image libraries put several KB on the stack; call them from a task with more stack.

↑↓ to move · Enter to open