ESP32 StoreProhibited: writing to an address that is not there
A StoreProhibited panic is the write side of LoadProhibited: the CPU tried to store a value at an address that is not writable memory. The cause is a pointer or an index you can find from the backtrace.
Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled. Core 0 register dump: PC : 0x400d2f1a PS : 0x00060830 A0 : 0x800d3044 A1 : 0x3ffbb2c0 ... EXCVADDR: 0x00000000 Backtrace: 0x400d2f17:0x3ffbb2c0 0x400d3041:0x3ffbb2e0 0x4008a1b2:0x3ffbb300
On RISC-V chips (ESP32-C3, C6, H2 and others) it is Store access fault, with the address in MTVAL.
Read EXCVADDR first
The register dump has the address the CPU tried to write 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 written 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
- Writing through a NULL pointer: a buffer that failed to allocate, a struct pointer never assigned.
- An index past the end of an array that walked into another variable's pointer and then wrote through it. The crash comes later and somewhere else, which is why it looks random.
sprintf,strcpyormemcpyinto a buffer that is too small. Usesnprintfand the real buffer size.- Writing to a string literal:
char *s = "abc"; s[0] = 'x';. Literals live in flash. (On the ESP32 that is usually reported as LoadStoreError instead.) - A task writing into an object that another task freed.
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.
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: LoadProhibited · CORRUPT HEAP · Stack overflow · IllegalInstruction. 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