Skip to content

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled. #2782

@knxhm

Description

@knxhm

What happened?

OpenDTU was running for several hours and then it crashed.

I (61532311) hoymiles: RX Period End
I (61532316) hoymiles: Success
V (61532600) temperature: Raw temperature value: 111
D (61565310) webapi: Websocket: [/livedata][103] disconnect
E (61565316) CORE: Too many messages queued: closing connection
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

Core 1 register dump:
PC : 0x40103ecf PS : 0x00060a30 A0 : 0x80104086 A1 : 0x3ffb2010
A2 : 0x00000000 A3 : 0x3ffb2048 A4 : 0x10394bac A5 : 0x00000002
A6 : 0x3ffc8484 A7 : 0x7a400000 A8 : 0x80103ef2 A9 : 0x3ffb1ff0
A10 : 0x3ffdc804 A11 : 0x3ffb2018 A12 : 0x0000071a A13 : 0x3fffe276
A14 : 0x00007d7d A15 : 0x65736c61 SAR : 0x0000001f EXCCAUSE: 0x0000001c
EXCVADDR: 0x10394bc0 LBEG : 0x4008c4c1 LEND : 0x4008c4d1 LCOUNT : 0xffffffef

Backtrace: 0x40103ecc:0x3ffb2010 0x40104083:0x3ffb2040 0x401040bd:0x3ffb2070 0x400fd795:0x3ffb2090 0x401d42b9:0x3ffb2210 0x400fe13a:0x3ffb2230 0x400fe2b5:0x3ffb2250 0x400fe2ce:0x3ffb2270 0x4012136d:0x3ffb2290

ELF file SHA256: 6831585f50471049

E (3949) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0
Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13232
load:0x40080400,len:3028
entry 0x400805e4
E (717) esp_core_dump_flash: No core dum���ѥѥ���found!
E (718) esp_core_dump_flash: No core dump partition found!
I (510) main: Starting OpenDTU
I (513) main: Mounting FS...
I (519) main: Reading configuration...
I (644) configuration: DTU serial check: Using existing serial
D (650) logging: Set default log level: 5
D (654) logging: Set log level for CORE: 1
I (658) main: Reading language pack...
I (668) main: Reading PinMapping...
I (701) main: Found valid mapping
I (705) main: Initializing Network...
I (820) network: Start configuring WiFi STA using new credentials
I (838) network: Configuring WiFi done

To Reproduce Bug

The code is basically a clone of the master branch with some modification in the NetworkSettings.cpp because I wanted to troubleshoot the sporadic wifi disconnects which I have. I attach the modified source file, see lines 112-114 and 266-268.
I dont think this modification have anything to do with the crash, it happened out of the blue while the ESP32 was just querying the inverters.
I also attach the ELF file.

firmware.elf.zip

NetworkSettings.cpp.zip

Expected Behavior

no crash.

Install Method

Self-Compiled

What git-hash/version of OpenDTU?

3f01b8d

What firmware variant (PIO Environment)?

generic_esp32

Relevant log/trace output

W (61531753) hoymiles: Nothing received, resend whole request
D (61531760) hoymiles: TX RealTimeRunData Channel: 75 --> 15 83 92 72 13 80 13 18 72 80 0B 00 68 8E 24 25 00 00 00 00 00 00 00 00 91 BB DA
V (61531837) hoymiles: Interrupt received
D (61531843) hoymiles: RX Channel: 40 --> 95 83 92 72 13 83 92 72 13 01 00 01 01 06 00 11 00 01 00 2C 00 03 00 00 05 02 AA | -80 dBm
V (61531866) hoymiles: Interrupt received
D (61531871) hoymiles: RX Channel: 23 --> 95 83 92 72 13 83 92 72 13 02 00 00 00 2B 00 66 00 03 00 08 00 02 00 01 00 00 D2 | -80 dBm
V (61531918) hoymiles: Interrupt received
D (61531924) hoymiles: RX Channel: 23 --> 95 83 92 72 13 83 92 72 13 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 10 8F | -80 dBm
V (61531989) hoymiles: Interrupt received
D (61531995) hoymiles: RX Channel: 3 --> 95 83 92 72 13 83 92 72 13 84 13 88 00 2C 00 D2 00 02 00 CF 01 0F 0C 43 80 1C 64 | -80 dBm
I (61532311) hoymiles: RX Period End
I (61532316) hoymiles: Success
V (61532600) temperature: Raw temperature value: 111
D (61565310) webapi: Websocket: [/livedata][103] disconnect
E (61565316) CORE: Too many messages queued: closing connection
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x40103ecf  PS      : 0x00060a30  A0      : 0x80104086  A1      : 0x3ffb2010  
A2      : 0x00000000  A3      : 0x3ffb2048  A4      : 0x10394bac  A5      : 0x00000002  
A6      : 0x3ffc8484  A7      : 0x7a400000  A8      : 0x80103ef2  A9      : 0x3ffb1ff0  
A10     : 0x3ffdc804  A11     : 0x3ffb2018  A12     : 0x0000071a  A13     : 0x3fffe276  
A14     : 0x00007d7d  A15     : 0x65736c61  SAR     : 0x0000001f  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x10394bc0  LBEG    : 0x4008c4c1  LEND    : 0x4008c4d1  LCOUNT  : 0xffffffef  


Backtrace: 0x40103ecc:0x3ffb2010 0x40104083:0x3ffb2040 0x401040bd:0x3ffb2070 0x400fd795:0x3ffb2090 0x401d42b9:0x3ffb2210 0x400fe13a:0x3ffb2230 0x400fe2b5:0x3ffb2250 0x400fe2ce:0x3ffb2270 0x4012136d:0x3ffb2290




ELF file SHA256: 6831585f50471049

E (3949) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0
Rebooting...

I decoded the hex dump and put it into chatGPT.

franz@debmini:~/opendtu/OpenDTU$ ~/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-addr2line -pfiaC -e .pio/build/generic_esp32/firmware.elf 0x40103ecc 0x40104083 0x401040bd 0x400fd795 0x401d42b9 0x400fe13a 0x400fe2b5 0x400fe2ce 0x4012136d
0x40103ecc: AsyncWebSocket::textAll(std::shared_ptr<std::vector<unsigned char, std::allocator<unsigned char> > >) at /home/franz/opendtu/OpenDTU/.pio/libdeps/generic_esp32/ESPAsyncWebServer/src/AsyncWebSocket.cpp:1063 (discriminator 1)
0x40104083: AsyncWebSocket::textAll(unsigned char const*, unsigned int) at /home/franz/opendtu/OpenDTU/.pio/libdeps/generic_esp32/ESPAsyncWebServer/src/AsyncWebSocket.cpp:1017
0x401040bd: AsyncWebSocket::textAll(char const*, unsigned int) at /home/franz/opendtu/OpenDTU/.pio/libdeps/generic_esp32/ESPAsyncWebServer/src/AsyncWebSocket.cpp:1020
 (inlined by) AsyncWebSocket::textAll(String const&) at /home/franz/opendtu/OpenDTU/.pio/libdeps/generic_esp32/ESPAsyncWebServer/src/AsyncWebSocket.cpp:1026
0x400fd795: WebApiWsLiveClass::sendDataTaskCb() at /home/franz/opendtu/OpenDTU/src/WebApi_ws_live.cpp:114
0x401d42b9: void std::__invoke_impl<void, void (WebApiWsLiveClass::*&)(), WebApiWsLiveClass*&>(std::__invoke_memfun_deref, void (WebApiWsLiveClass::*&)(), WebApiWsLiveClass*&) at /home/franz/.platformio/packages/toolchain-xtensa-esp32/xtensa-esp32-elf/include/c++/8.4.0/bits/invoke.h:73
 (inlined by) std::__invoke_result<void (WebApiWsLiveClass::*&)(), WebApiWsLiveClass*&>::type std::__invoke<void (WebApiWsLiveClass::*&)(), WebApiWsLiveClass*&>(void (WebApiWsLiveClass::*&)(), WebApiWsLiveClass*&) at /home/franz/.platformio/packages/toolchain-xtensa-esp32/xtensa-esp32-elf/include/c++/8.4.0/bits/invoke.h:95
 (inlined by) void std::_Bind<void (WebApiWsLiveClass::*(WebApiWsLiveClass*))()>::__call<void, , 0u>(std::tuple<>&&, std::_Index_tuple<0u>) at /home/franz/.platformio/packages/toolchain-xtensa-esp32/xtensa-esp32-elf/include/c++/8.4.0/functional:400
 (inlined by) void std::_Bind<void (WebApiWsLiveClass::*(WebApiWsLiveClass*))()>::operator()<, void>() at /home/franz/.platformio/packages/toolchain-xtensa-esp32/xtensa-esp32-elf/include/c++/8.4.0/functional:484
 (inlined by) std::_Function_handler<void (), std::_Bind<void (WebApiWsLiveClass::*(WebApiWsLiveClass*))()> >::_M_invoke(std::_Any_data const&) at /home/franz/.platformio/packages/toolchain-xtensa-esp32/xtensa-esp32-elf/include/c++/8.4.0/bits/std_function.h:297
0x400fe13a: std::function<void ()>::operator()() const at /home/franz/.platformio/packages/toolchain-xtensa-esp32/xtensa-esp32-elf/include/c++/8.4.0/bits/std_function.h:687
0x400fe2b5: Scheduler::execute() at /home/franz/opendtu/OpenDTU/.pio/libdeps/generic_esp32/TaskScheduler/src/TaskScheduler.h:1552
 (inlined by) Scheduler::execute() at /home/franz/opendtu/OpenDTU/.pio/libdeps/generic_esp32/TaskScheduler/src/TaskScheduler.h:1351
0x400fe2ce: loop() at /home/franz/opendtu/OpenDTU/src/main.cpp:136
0x4012136d: loopTask(void*) at /home/franz/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:50
ChatGPT said:

Danke für die vollständige Dekodierung – die Ausgabe ist sehr aufschlussreich. Hier die Ursache und konkrete Hinweise, was du tun kannst, um den Crash zu beheben:
💥 Was ist passiert?

Der Crash wird durch folgenden Aufruf verursacht:

AsyncWebSocket::textAll(String const&)

in Verbindung mit:

WebApiWsLiveClass::sendDataTaskCb()

aus deiner Datei:

/home/franz/opendtu/OpenDTU/src/WebApi_ws_live.cpp:114

Das bedeutet: Du versuchst vermutlich über textAll() Daten an alle verbundenen WebSocket-Clients zu senden, aber die Verbindung ist bereits geschlossen oder nicht gültig – was zu einem LoadProhibited (null pointer dereference) führt.
📌 Hauptursache

textAll() ruft intern textAll(std::shared_ptr<std::vector<uint8_t>>) auf. Wenn keine Clients mehr verbunden sind (oder sie asynchron getrennt wurden), wird vermutlich auf einen ungültigen oder bereits freigegebenen Pointer zugegriffen → Crash.
✅ Was du tun kannst (Fix-Ideen)
🔒 1. Vor dem Aufruf von textAll() prüfen, ob Clients verbunden sind:

if (ws->count() > 0) {
    ws->textAll(payload);
}

ws ist dabei deine Instanz von AsyncWebSocket.
🧯 2. Absichern des Pointer-Zugriffs in sendDataTaskCb()

Wenn du mit einem Scheduler arbeitest, achte darauf, dass der Callback nicht mehr aufgerufen wird, nachdem der WebSocket freigegeben wurde. Beispiel:

void WebApiWsLiveClass::sendDataTaskCb() {
    if (!ws) return; // Schutz gegen nullptr
    if (ws->count() == 0) return; // niemand verbunden
    ws->textAll(payload);
}

🧵 3. Asynchrone Trennung berücksichtigen

WebSocket-Clients können sich asynchron trennen. Falls textAll() innerhalb eines Tasks oder Schedulers ausgeführt wird, musst du sicherstellen, dass in der Zwischenzeit kein ws->close() oder ws = nullptr passiert ist.
🧪 4. Loggen vor dem Senden

Debug-Ausgaben helfen dir, das Timing zu analysieren:

ESP_LOGI("WebSocket", "Sending to %d clients", ws->count());

🧠 Fazit

Dein Fehler ist ein klassischer Fall von "use-after-close/null" im Zusammenhang mit WebSocket + Task Scheduler.
Du kannst ihn beheben, indem du vor textAll() prüfst, ob Clients verbunden sind und ob der ws-Pointer noch gültig ist.

Wenn du mir die betroffene Funktion sendDataTaskCb() zeigen willst, kann ich dir den passenden Schutz dort direkt einbauen.

Anything else?

No response

Please confirm the following

  • I believe this issue is a bug that affects all users of OpenDTU, not something specific to my installation.
  • I have already searched for relevant existing issues and discussions before opening this report.
  • I have updated the title field above with a concise description.
  • I have double checked that my inverter does not contain a W in the model name (like HMS-xxxW) as they are not supported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstale

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions