Guru Meditation Error: Core 0 panic’ed, cause by cause

The ESP-IDF panic handler caught a CPU exception or a failed system check. The words in the parentheses are the cause, and the register dump and backtrace under the line say where it happened.

The line

Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x400e14ed  PS      : 0x00060030  A0      : 0x800d0805  A1      : 0x3ffb5030
A2      : 0x00000000  A3      : 0x00000001  A4      : 0x00000001  A5      : 0x3ffb50dc
A14     : 0x3ffb7078  A15     : 0x00000000  SAR     : 0x00000014  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0xffffffff

Backtrace: 0x400e14ed:0x3ffb5030 0x400d0802:0x3ffb5050

An ESP32 (Xtensa) dump, shortened; the register values follow the example in the ESP-IDF guide. EXCVADDR: 0x00000000 is the address that was read.

What it means

Every fatal error in ESP-IDF ends in the panic handler, which prints the cause in parentheses and then acts on CONFIG_ESP_SYSTEM_PANIC. The default is to print the registers and the backtrace and restart the chip, so on the console the dump is followed by a new boot. The other choices halt, reboot silently or start a GDB stub on the UART.

The backtrace line holds PC:SP pairs, innermost frame first. IDF Monitor turns each PC into a function, file and line as it prints; other serial tools show the raw addresses. The cause names on this page are those of the Xtensa chips (ESP32, ESP32-S2, ESP32-S3); the RISC-V chips such as the ESP32-C3 print different names, listed in the same guide for that chip.

Causes printed in the parentheses

Applies to: ESP32, ESP-IDF v5.4.

CauseWhat the guide says it isLook at
LoadProhibited, StoreProhibitedA read or write to an invalid address.EXCVADDR: 0 is a NULL pointer, a small value a struct member through a NULL pointer, garbage an uninitialised or corrupted pointer.
IllegalInstructionThe instruction executed was not valid.A task function that returned, the SPI flash pins, a C++ function missing its return.
InstrFetchProhibitedThe CPU could not read an instruction from that address.PC: zero or a value outside 0x4xxxxxxx means a bad function pointer.
IntegerDivideByZeroAn integer division by zero.The top backtrace frame.
LoadStoreAlignmentThe address alignment does not match the access size.Casts of byte buffers to wider types.
LoadStoreErrorAn 8 or 16 bit access to 32 bit only memory, or a write to read-only memory.Writes through pointers into flash-mapped data or code.
Interrupt wdt timeout on CPU0/CPU1Interrupts were blocked for longer than the interrupt watchdog allows.Long critical sections and ISRs.
Cache disabled but cached memory region accessedCode or data in flash was touched while the flash cache was off.ISRs registered as IRAM-safe that call code outside IRAM.
Unhandled debug exceptionA BREAK instruction ran, or a watchpoint fired.A Stack canary watchpoint triggered (task) line: that task overflowed its stack.

Source: ESP-IDF v5.4 Programming Guide: Fatal Errors, Guru Meditation Errors

Common causes

LoadProhibited or StoreProhibited: a bad pointer

The application read from or wrote to an address that is not mapped. The address is in EXCVADDR. Zero usually means a NULL pointer was dereferenced, a value close to zero that a member of a structure was accessed through a NULL pointer, and anything outside the 0x3fxxxxxx to 0x6xxxxxxx range that the pointer was never initialised or has been overwritten.

Source: ESP-IDF v5.4 Programming Guide: Fatal Errors, LoadProhibited, StoreProhibited

IllegalInstruction: a task that returned, or flash that could not be read

The guide names three common reasons. A FreeRTOS task function returned instead of calling vTaskDelete(). The next instruction could not be read from SPI flash, because the application reconfigured the flash pins or something external is connected to them. Or a C++ function declared to return a value ran off its end, which the build normally rejects through -Werror=return-type unless warnings were turned off.

Source: ESP-IDF v5.4 Programming Guide: Fatal Errors, IllegalInstruction

InstrFetchProhibited: a call through a bad function pointer

The CPU tried to fetch an instruction from an address outside instruction RAM and ROM. This usually means a call through a function pointer that does not point at code: a callback that was never set, or one stored in an object that has been freed. PC is then zero or a garbage value.

Source: ESP-IDF v5.4 Programming Guide: Fatal Errors, InstrFetchProhibited

Cache disabled but cached memory region accessed: an ISR outside IRAM

While ESP-IDF writes or erases SPI flash it switches the flash cache off, suspends tasks and leaves only interrupt handlers registered with ESP_INTR_FLAG_IRAM enabled. If such a handler calls a function or reads a constant that still lives in flash, the access fails with this cause. It tends to appear only when a flash write (NVS, OTA, a file system) coincides with the interrupt.

Source: ESP-IDF v5.4 Programming Guide: Fatal Errors, Cache disabled but cached memory region accessed

Interrupt wdt timeout: interrupts blocked too long

The interrupt watchdog is fed from the FreeRTOS tick interrupt on each CPU. When the tick cannot run within CONFIG_ESP_INT_WDT_TIMEOUT_MS, because a critical section or an interrupt handler is running for too long, the watchdog invokes the panic handler with this cause.

Source: ESP-IDF v5.4 Programming Guide: Watchdogs, Interrupt Watchdog Timer

A stack overflow in a task

With CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK on, a watchpoint guards the last 32 bytes of the running task’s stack, and hitting it prints Debug exception reason: Stack canary watchpoint triggered (task_name). Not every overflow trips it: a task that writes past the watched bytes corrupts memory and fails later with another cause.

Source: ESP-IDF v5.4 Programming Guide: Fatal Errors, Stack overflow

What to check first

  1. Read the cause in the parentheses and the core number, then find it in the table above: it tells you which register matters.
  2. For LoadProhibited and StoreProhibited read EXCVADDR; for InstrFetchProhibited read PC. A zero or near-zero value means a NULL pointer, and the top backtrace frame is where it was used.
  3. Decode the backtrace against the ELF of the firmware that is actually on the board: idf.py monitor does it as the lines arrive, and xtensa-esp32-elf-addr2line -pfiaC -e build/<project>.elf <PC values> does it for a saved log.
  4. Look at the lines above the Guru Meditation line as well. Stack canary watchpoint triggered, CORRUPT HEAP and assert failed lines are printed there and name the real problem.
  5. If the cause changes from run to run, suspect memory corruption: turn on heap poisoning (CONFIG_HEAP_POISONING_COMPREHENSIVE) and the stack watchpoint, and give the suspected task a larger stack.
  6. If the board restarts too fast to read the dump, set CONFIG_ESP_SYSTEM_PANIC to print and halt, or set CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS, and keep the serial log.

In NeuroTerm

On a serial tab with pattern markers on, NeuroTerm recognises this line as “Board crash: ESP panic”. A coding agent connected through Terminal Use gets that name in its list of tabs and among the markers of the output it reads, with a cursor for reading the lines around it. Setup is in Terminal Use (MCP).