Fix "Guru Meditation Error: Core 1 panic'ed (LoadProhibited)" on ESP32
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
- Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.
- Guru Meditation Error: Core 0 panic'ed (Load access fault). Exception was unhandled.
- Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).
- ***ERROR*** A stack overflow in task loopTask has been detected.
- E (10123) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
The ESP32 crashed on a CPU exception and reboots: with LoadProhibited, the program read an invalid memory address, most often through a null pointer. Decode the backtrace to get the faulty file and line, then fix the pointer, the task stack size or the out-of-bounds access.
What this error means
"Guru Meditation Error" is the message of the ESP-IDF panic handler, also used by the Arduino ESP32 core. The given core (Core 1 runs setup() and loop() in Arduino, Core 0 the Wi-Fi and Bluetooth stack) raised an exception that nothing handled. The type in parentheses says what happened: LoadProhibited or StoreProhibited for a read or write at an invalid address, InstrFetchProhibited for a jump to an invalid address, Load access fault on RISC-V chips (ESP32-C3, C6, H2). Then come the registers (PC, EXCVADDR = faulty address), the Backtrace: line and a reboot.
Common causes
- Null or uninitialized pointer: object never created,
malloc()returnedNULL, sensor whose init failed. AnEXCVADDRclose to0x00000000(for example0x0000000c) points to accessing a struct member through a null pointer. - Task stack too small: large local arrays in
loop()or in a FreeRTOS task created with a tight stack. In ESP-IDF, the size passed toxTaskCreate()is in bytes, not words. - Corrupted memory: writing past the end of an array, pointer to a local variable that no longer exists,
String.c_str()of a temporary object, doublefree(). - Non-
voidfunction withoutreturn: in C++ this is undefined behavior, and on ESP32 it often ends inIllegalInstructionorInstrFetchProhibited. - Badly written interrupt or blocking loop: ISR without
IRAM_ATTR,Serial.print()ordelay()inside an ISR,whileloop with no pause that starves the watchdog (Task watchdog got triggered,Interrupt wdt timeout).
Step-by-step fix
-
Read the exception type and EXCVADDR
Copy the whole block, from "Guru Meditation Error" down to the
Backtrace:line. Note the exception type, the core andEXCVADDR. If the monitor scrolls too fast because of the reboots, unplug the board right after the crash or make it halt on panic (see FAQ).Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled. PC : 0x400d1a2b PS : 0x00060a30 A0 : 0x800d2c3d A1 : 0x3ffb2270 EXCVADDR: 0x0000000c LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff Backtrace: 0x400d1a28:0x3ffb2270 0x400d2c3a:0x3ffb2290 0x400d5e11:0x3ffb22b0 -
Decode the backtrace
The addresses mean nothing until they are translated into file and line. With ESP-IDF,
idf.py monitordoes it automatically. With PlatformIO, add theesp32_exception_decoderfilter. With Arduino IDE 1.8, use the EspExceptionDecoder tool (Tools > ESP Exception Decoder); with IDE 2.x, install the community esp-exception-decoder extension or runaddr2lineon the.elffile in the build folder (path shown with verbose compile output).# ESP-IDF: decodes the backtrace live idf.py -p /dev/ttyUSB0 flash monitor # PlatformIO (platformio.ini) # monitor_filters = esp32_exception_decoder # build_type = debug # Manual decoding (use riscv32-esp-elf-addr2line on C3/C6/H2) xtensa-esp32-elf-addr2line -pfiaC -e build/firmware.elf 0x400d1a28 0x400d2c3a 0x400d5e11 -
Check pointers before use
At the reported line, find the dereferenced pointer. Always check the return values of
malloc(),new (std::nothrow),begin()functions and lookups that may find nothing, and stop cleanly instead of carrying on withNULL.uint8_t *buf = (uint8_t *)malloc(4096); if (buf == nullptr) { Serial.println("malloc failed"); return; } Sensor *sensor = findSensor(id); if (sensor != nullptr) { value = sensor->read(); } -
Enlarge the stack or move large arrays out
Measure the remaining stack margin with
uxTaskGetStackHighWaterMark(): a value close to 0 confirms the problem. Give the task more stack, or move large arrays tostaticor the heap. In Arduino, theloop()stack (8 KB by default) is set withSET_LOOP_TASK_STACK_SIZE().SET_LOOP_TASK_STACK_SIZE(16 * 1024); // Arduino core: loop() stack in bytes void worker(void *arg) { static uint8_t frame[8192]; // static: not on the task stack for (;;) { Serial.printf("free stack: %u\n", uxTaskGetStackHighWaterMark(NULL)); vTaskDelay(pdMS_TO_TICKS(1000)); } } void setup() { Serial.begin(115200); // stack size in bytes on ESP-IDF / Arduino ESP32 xTaskCreatePinnedToCore(worker, "worker", 8192, NULL, 1, NULL, 1); } void loop() {} -
Write safe interrupts
An ISR must live in IRAM, stay very short and never call
Serial,delay(),malloc()or Wi-Fi. Set avolatileflag and do the work inloop()or a task.volatile bool pressed = false; void IRAM_ATTR onButton() { pressed = true; } void setup() { Serial.begin(115200); pinMode(0, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(0), onButton, FALLING); } void loop() { if (pressed) { pressed = false; Serial.println("button"); } } -
Watchdog variant: yield to the system
Task watchdog got triggeredorInterrupt wdt timeoutmeans a task hogged the CPU without ever yielding. Add adelay(1)orvTaskDelay()in long loops and replace busy-waiting with a blocking wait. Disabling the watchdog hides the hang instead of fixing it: a frozen device will no longer reboot by itself.// Bad: busy loop, starves the watchdog // while (!dataReady) {} // Good: yield while waiting while (!dataReady) { vTaskDelay(pdMS_TO_TICKS(1)); }
Did this fix work for you?
Confirm it in one click: it will rise for the next developers stuck on the same error.
Keep it from coming back
- Turn on all compiler warnings (Arduino IDE: Preferences > Compiler warnings > All): they flag functions without
returnand many dubious pointers. - Set up backtrace decoding from the start of the project, so a crash immediately gives you a file and line.
- Watch
uxTaskGetStackHighWaterMark()during development and keep a margin of at least 1 KB per task.
Frequently asked questions
What does LoadProhibited mean on ESP32?
The CPU tried to read from an address that is not valid memory. If EXCVADDR is 0x00000000 or a small value, it is almost always a null pointer.
How do I stop the ESP32 from reboot-looping after the panic?
In ESP-IDF, idf.py menuconfig > Component config > ESP System Settings > Panic handler behaviour, pick "Print registers and halt" (CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT). The board stops and the message stays readable.
Why Core 1 and not Core 0?
In Arduino, setup() and loop() run on Core 1: a crash on that core usually comes from your code. On Core 0, look at Wi-Fi or Bluetooth callbacks and the tasks you pinned there.
Useful tools for this error
More Electronics & Arduino errors
- Fix "avrdude: stk500_getsync(): not in sync" on Arduino
- Fix "Failed to connect to ESP32" (Wrong boot mode, No serial data received)
- Fix "Brownout detector was triggered" on ESP32
- Fix "can't open device /dev/ttyUSB0: Permission denied" (Arduino, ESP32)
- Fix "error: 'x' was not declared in this scope" (Arduino, C++)
- Fix "Sketch too big" on Arduino and ESP32 (flash memory full)
- Fix "OSError: [Errno 121] Remote I/O error" with I2C on Raspberry Pi