C++ exceptions do not work inside threads
Posted: Fri Nov 10, 2017 2:27 pm
Hi,
I use ESP-IDF v3.01 (I guess, last commit is from Oct 19th). I enabled C++ exceptions and they work in the main program code. But when creating a thread using xTaskCreate() and with a try-catch block in the thread function, when a C++ exception is thrown, it does not reach the catch block. Instead it comes to a panic.
LightProtocolServerTask() is my thread function. ExceptionTestFunc() is called by the thread function and throws an exception.
I use ESP-IDF v3.01 (I guess, last commit is from Oct 19th). I enabled C++ exceptions and they work in the main program code. But when creating a thread using xTaskCreate() and with a try-catch block in the thread function, when a C++ exception is thrown, it does not reach the catch block. Instead it comes to a panic.
Code: Select all
0x40087b64: invoke_abort at D:/dev/esp-idf/components/esp32/panic.c:553
0x40087c63: abort at D:/dev/esp-idf/components/esp32/panic.c:553
0x4013550f: __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc:112
0x40135556: std::terminate() at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc:112
0x401344b3: __cxa_throw at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_throw.cc:87
0x40107d21: ExceptionTestFunc() at d:\dev\msys32\opt\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0/functional:1871
0x40107d46: LightProtocolServerTask(void*) at d:\dev\msys32\opt\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0/functional:1871