Puara / puara-module

Library for creating music controllers using the Puara framework
MIT License
0 stars 5 forks source link

ESP32 crash when saving settings in the webpage #9

Open aburt2 opened 6 months ago

aburt2 commented 6 months ago

when you have a large amount of variables in the settings.json (more than about 7-8), the ESP32S3 crashes when saving variables through the webpage. Error indicates its something to do with the settings_posthandler method, specifically line 809.

https://github.com/Puara/puara-module/blob/84f39b252c164c8e658f0cc0e6870a17b60819eb/puara.cpp#L809-L812

Error below:

spiffs: SPIFFS unmounted
startWifi: Starting WiFi config
wifi_init: hostname: TStick_513
wifi_init: setting wifi mode
wifi_init:     AP-STA mode
wifi_init: loading AP config
wifi_init: loading STA config
wifi_init: esp_wifi_start
wifi_init: wifi_init finished.
wifi/sta_event_handler: got ip:192.168.86.37
wifi_init: Connected to SSID: tstick-network
webserver: Starting server on port: 80
webserver: Registering URI handlers
MDNS Init completed. Device name: TStick_513

Settings stored:
enable_libmapper: 1.000000
fsr_offset: 2000.000000
touch_noise: 0.000000
jabx_threshold: 5.000000
jaby_threshold: 5.000000
jabz_threshold: 5.000000
soft_offsetx1: 1.000000
soft_offsetx2: 0.000000

abort() was called at PC 0x420b466b on core 1

Backtrace: 0x403781ce:0x3fcb36f0 0x4037ef1d:0x3fcb3710 0x40385b01:0x3fcb3730 0x420b466b:0x3fcb37b0 0x420b46b2:0x3fcb37d0 0x420a3f83:0x3fcb37f0 0x420a6077:0x3fcb3810 0x42024561:0x3fcb3830 0x42026495:0x3fcb3850 0x4205aa22:0x3fcb3b30 0x4205b684:0x3fcb3b60 0x4205a376:0x3fcb3c00 0x42059a6c:0x3fcb3c20 0x420e8dc6:0x3fcb3c40 0x42059b84:0x3fcb3c60

  #0  0x403781ce:0x3fcb36f0 in panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:408
  #1  0x4037ef1d:0x3fcb3710 in esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:137
  #2  0x40385b01:0x3fcb3730 in abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/abort.c:46   
  #3  0x420b466b:0x3fcb37b0 in __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32s3-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
  #4  0x420b46b2:0x3fcb37d0 in std::terminate() at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32s3-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:57
  #5  0x420a3f83:0x3fcb37f0 in __cxa_throw at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32s3-elf/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:95
  #6  0x420a6077:0x3fcb3810 in std::__throw_out_of_range(char const*) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32s3-elf/src/gcc/libstdc++-v3/src/c++11/functexcept.cc:82 (discriminator 2)
  #7  0x42024561:0x3fcb3830 in std::__detail::_Map_base<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, int>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, int> >, std::__detail::_Select1st, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true>, true>::at(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) at c:\users\albert\.platformio\packages\toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5\xtensa-esp32s3-elf\include\c++\8.4.0\bits/hashtable_policy.h:760
  #8  0x42026495:0x3fcb3850 in std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, int> > >::at(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) at c:\users\albert\.platformio\packages\toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5\xtensa-esp32s3-elf\include\c++\8.4.0\bits/unordered_map.h:991
      (inlined by) Puara::settings_post_handler(httpd_req*) at .pio/libdeps/enchantis3/puara-module/puara.cpp:809
  #9  0x4205aa22:0x3fcb3b30 in httpd_uri at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_http_server/src/httpd_uri.c:329
  #10 0x4205b684:0x3fcb3b60 in httpd_parse_req at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_http_server/src/httpd_parse.c:659
      (inlined by) httpd_req_new at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_http_server/src/httpd_parse.c:787
  #11 0x4205a376:0x3fcb3c00 in httpd_sess_process at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_http_server/src/httpd_sess.c:419 (discriminator 15)
  #12 0x42059a6c:0x3fcb3c20 in httpd_process_session at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_http_server/src/httpd_main.c:178
      (inlined by) httpd_process_session at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_http_server/src/httpd_main.c:163
  #13 0x420e8dc6:0x3fcb3c40 in httpd_sess_enum at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_http_server/src/httpd_sess.c:50 (discriminator 1)
  #14 0x42059b84:0x3fcb3c60 in httpd_server at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_http_server/src/httpd_main.c:228
      (inlined by) httpd_thread at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_http_server/src/httpd_main.c:250

ELF file SHA256: 5cb9d890fba63067
aburt2 commented 6 months ago

@edumeneses

edumeneses commented 6 months ago

Can you share the firmware (link) that is giving this error?

It seems either variables.at or variables_fields.at do not find a match in the vector or unordered_map. You can replace .at for square brackets (for variables only and then for variables_fields only) to see if the error vanishes (it will not fix the problem but can tell us the failing point. It could be a problem with the field name that is not being parsed correctly.

aburt2 commented 6 months ago

This is the firmware link: https://github.com/aburt2/T-Stick/tree/5gw-main/firmware And this is the settings.json file: https://github.com/aburt2/T-Stick/blob/5gw-main/firmware/data/settings.json

I'll try what you are suggesting and see if it works

edumeneses commented 6 months ago

Thanks. I will try to try it on my end as soon as possible