ESP32 LoadProhibited: reading from an address that is not there
A LoadProhibited panic means the CPU tried to read memory at an address that does not exist or is not readable. Almost always a pointer: NULL, uninitialized, or already freed.
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled. Core 1 register dump: PC : 0x400d1d4e PS : 0x00060630 A0 : 0x800d1e5c A1 : 0x3ffb2270 ... EXCVADDR: 0x0000000c LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000 Backtrace: 0x400d1d4b:0x3ffb2270 0x400d1e59:0x3ffb2290 0x40089ec6:0x3ffb22b0
On the ESP32-C3, C6, H2 and the other RISC-V chips the same mistake is reported as Load access fault, with the address in MTVAL.
Read EXCVADDR first
The register dump has the address the CPU tried to read in EXCVADDR (in MTVAL on RISC-V chips). It tells you most of the story:
0x00000000: a NULL pointer was dereferenced.- A small number, like
0x0000000c: a member of a structure was read through a NULL pointer to it. The number is the member's offset. - Anything else outside
0x3fxxxxxxto0x6xxxxxxx: the pointer was never initialized, or something overwrote it.
The usual causes
- A function returned NULL and the result was used anyway:
malloc,strstr,cJSON_GetObjectItem, a lookup in your own list. Check the return value. - A pointer used before it was set: a global handle read by a task that started before
app_mainorsetup()created it. - A pointer used after it was freed, or a task reading an object another task deleted.
- A string without its terminating zero, so
strlenorprintf("%s")runs off the end into unmapped memory. - Arduino: a
Stringor object captured by reference in a callback (a web server handler, a timer) that has gone out of scope by the time the callback runs.
Find the line
The Backtrace: line is a list of PC:SP pairs, innermost call first. To turn the addresses into functions and lines you need the ELF of exactly the build that crashed:
- ESP-IDF:
idf.py monitordecodes it as it prints. For a backtrace you copied,xtensa-esp32-elf-addr2line -pfiaC -e build/app.elf 0x400d1d4b 0x400d1e59(riscv32-esp-elf-addr2lineon the C3, C6 and other RISC-V chips). - Arduino: the ELF is in the sketch's build folder (Sketch → Export Compiled Binary, or the path in the verbose build output).
- In the browser: paste the crash and drop the ELF into the free ESP32 exception decoder. Nothing is uploaded.
The first address in the backtrace is the instruction that did the read. The line it points to dereferences the bad pointer; the lines below it show where that pointer came from.
When it happens in the field
On your desk the crash prints to the serial monitor. On a device in someone else's building it prints to a port nobody is reading, the chip restarts, and all you hear is that it "sometimes hangs". Pinscope keeps the panic reason and backtrace across the restart, sends them on the next connection and decodes them with the ELF of the build that crashed, so you get the function and line without anyone at the device. Free for three devices. How crash reporting from the field works.
Related errors: StoreProhibited · InstrFetchProhibited · CORRUPT HEAP · Stack overflow. All ESP32 errors: the list. Messages and causes from ESP-IDF's panic handler and Espressif's Fatal Errors guide.
More
- Remote access to an ESP32 without TLS: what it measured and what it costs
- Reaching an ESP32 web server from outside its network
- Updating ESP32 firmware over the internet, with rollback
- Guru Meditation Error: decoding the backtrace, and crashes from the field
- Remote logging: ESP_LOG without a serial cable
- Heap and stack monitoring in the field
- An ESP32 behind CGNAT, 4G or Starlink
- TLS memory usage on the ESP32, and how to reduce it
- Sharing an ESP32 sensor page with anyone, without port forwarding
- ArduinoOTA over the internet, with a rollback
- ESP32 remote access compared: port forwarding, ngrok, Cloudflare Tunnel, Tailscale
- esp_http_server slow? The 250 ms delay and the fix
- Before the first ESP32 ships: a field support checklist
- ESP32 exception decoder: a Guru Meditation backtrace to lines, in the browser