atanisoft / ESP32CommandStation

An ESP32 based DCC Command Station with integrated OpenLCB (LCC) --- NOTE: this project is not under active development.
https://atanisoft.github.io/ESP32CommandStation/
GNU General Public License v3.0
90 stars 34 forks source link

Sync HttpServer #84

Closed atanisoft closed 3 years ago

TrainzLuvr commented 3 years ago

I'll add this crash here, since it's probably related to this PR and not the dcc branch.

abort() was called at PC 0x400d5c47 on core 1
0x400d5c47: __cxa_end_catch at C:/espressif/esp-idf/components/cxx/cxx_exception_stubs.cpp:13

Backtrace:0x40088c7e:0x3ffd2cf0 0x40089291:0x3ffd2d10 0x4008fd91:0x3ffd2d30 0x400d5c47:0x3ffd2db0 0x40195bb1:0x3ffd2dd0 0x40196159:0x3ffd2df0 0x401962d8:0x3ffd2e10 0x401967e1:0x3ffd2e50 0x4019685a:0x3ffd2e70 0x4019686d:0x3ffd2e90 0x400eb4f9:0x3ffd2eb0 0x401a7577:0x3ffd2f80 0x401159a1:0x3ffd2fa0 0x40119bf1:0x3ffd2ff0 0x401199fd:0x3ffd3020 0x401a8259:0x3ffd3050 0x40125e37:0x3ffd3070

0x40088c7e: panic_abort at C:/espressif/esp-idf/components/esp_system/panic.c:341

0x40089291: esp_system_abort at C:/espressif/esp-idf/components/esp_system/system_api.c:106

0x4008fd91: abort at C:/espressif/esp-idf/components/newlib/abort.c:46

0x400d5c47: __cxa_end_catch at C:/espressif/esp-idf/components/cxx/cxx_exception_stubs.cpp:13

0x40195bb1: operator new(unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/new_op.cc:54

0x40196159: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/no-rtti/libstdc++-v3/include/ext/new_allocator.h:111
 (inlined by) ?? at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/no-rtti/libstdc++-v3/include/bits/alloc_traits.h:436
 (inlined by) std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/no-rtti/libstdc++-v3/include/bits/basic_string.tcc:153

0x401962d8: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned int, unsigned int, char const*, unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/no-rtti/libstdc++-v3/include/bits/basic_string.tcc:317

0x401967e1: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/no-rtti/libstdc++-v3/include/bits/basic_string.tcc:370

0x4019685a: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::append(char const*) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/no-rtti/libstdc++-v3/include/bits/basic_string.h:1259

0x4019686d: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/no-rtti/libstdc++-v3/include/bits/basic_string.h:1169

0x400eb4f9: process_loco(http::HttpRequest*) at r:\code\esp32commandstation\build/../main/WebServer.cpp:1071

0x401a7577: std::_Function_handler<http::AbstractHttpResponse* (http::HttpRequest*), http::AbstractHttpResponse* (*)(http::HttpRequest*)>::_M_invoke(std::_Any_data const&, http::HttpRequest*&&) at c:\espressif\tools\xtensa-esp32-elf\esp-2020r2-8.2.0\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\8.2.0\bits/std_function.h:282

0x401159a1: http::HttpRequestFlow::process_request_handler() at c:\espressif\tools\xtensa-esp32-elf\esp-2020r2-8.2.0\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\8.2.0\bits/std_function.h:687  (inlined by) http::HttpRequestFlow::process_request_handler() at r:\code\esp32commandstation\build/../components/HttpServer/src/HttpRequestFlow.cpp:398

0x40119bf1: StateFlowBase::run() at r:\code\esp32commandstation\build/../components/OpenMRNLite/src/executor/StateFlow.cpp:63 (discriminator 4)

0x401199fd: ExecutorBase::entry() at r:\code\esp32commandstation\build/../components/OpenMRNLite/src/executor/Executor.cpp:324

0x401a8259: OSThread::start(void*) at r:\code\esp32commandstation\build/../components/OpenMRNLite/src/os/OS.hxx:193

0x40125e37: os_thread_start at r:\code\esp32commandstation\build/../components/OpenMRNLite/src/os/os.c:391

Funny thing is, it just crashed without me doing anything. ESP32 was basically idling...

atanisoft commented 3 years ago

That crash looks like it was trying to convert the currently active locos into a json object to display by the status webpage. It looks unlikely to be due to this PR but not entirely unrelated.

TrainzLuvr commented 3 years ago

Hmm I did fiddle with the WebUI, but that's about it.

Maybe I should've done that before applying this PR just to compare, but here it is now, either way. :)

atanisoft commented 3 years ago

Yeah, I think it is likely related to https://github.com/atanisoft/ESP32CommandStation/issues/78 which is problematic due to the underlying stack memory usage (until it TX a frame it holds a copy with no hard limit)

TrainzLuvr commented 3 years ago

Could a check be added for consequent frames so duplicates are not stored, and only one copy is held thus keeping the heap within bounds?

atanisoft commented 3 years ago

That is similar to what was proposed but not yet implemented.