yubox-node-org / AsyncTCPSock

Reimplementation of the API of me-no-dev/AsyncTCP using high-level BSD sockets
GNU Lesser General Public License v3.0
20 stars 10 forks source link

Crash when turning off WiFi. #9

Open davidkleng opened 2 years ago

davidkleng commented 2 years ago

Issue: ESP32 crashes when turning off web sockets, web server and wifi.

Serial monitor:

assert failed: heap_caps_free heap_caps.c:304 (heap != NULL && "free() target pointer is outside heap areas")

Backtrace:0x40083c21:0x3ffb25400x4008d011:0x3ffb2560 0x40092275:0x3ffb2580 0x400840ce:0x3ffb26b0 0x400922a5:0x3ffb26d0 0x40168d7d:0x3ffb26f0 0x400f2041:0x3ffb2710 0x40180c27:0x3ffb2730 0x400fbb4d:0x3ffb2750 0x400fbba1:0x3ffb2770 0x400e4800:0x3ffb27c0 0x400e5aac:0x3ffb27e0 0x40103515:0x3ffb2820 
  #0  0x40083c21:0x3ffb25400 in panic_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/panic.c:402

ELF file SHA256: 0000000000000000

Rebooting...

The decoded backtrace:

Decoding stack results
0x40083c21: panic_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/panic.c line 402
0x4008d011: esp_system_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/esp_system.c line 121
0x40092275: __assert_func at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/assert.c line 85
0x400840ce: heap_caps_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps.c line 289
0x400922a5: free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/heap.c line 46
0x40168d7d: operator delete(void*) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/del_op.cc line 49
0x400f2041: AsyncWebSocket::~AsyncWebSocket() at .pio/libdeps/esp32dev/ESP Async WebServer/src/AsyncWebSocket.cpp line 767
0x40180c27: std::_Function_handler   >::_M_invoke(const std::_Any_data &, AsyncWebHandler * const&) at .pio/libdeps/esp32dev/ESP Async WebServer/src/WebServer.cpp line 41
0x400fbb4d: std::function ::operator()(AsyncWebHandler* const&) const at c:\users\david\.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\include\c++\8.4.0\bits/std_function.h line 260
0x400fbba1: AsyncWebServer::reset() at .pio/libdeps/esp32dev/ESP Async WebServer/src/StringArray.h line 35
0x400e4800: restartServer() at src/server.hpp line 2126
0x400e5aac: loop() at src/main.cpp line 229
0x40103515: loopTask(void*) at C:/Users/david/.platformio/packages/framework-arduinoespressif32@src-537c58760dafe7fcc8a1d9bbcf00b6f6/cores/esp32/main.cpp line 46

Finally, the code:

ws.closeAll(); // close web sockets
server.end();
WiFi.disconnect();
WiFi.mode(WIFI_MODE_NULL);