src/devdrivers/CH32V003.cpp causes crash every time its begin() method is called.

#418 · closed · 1 comments

View on GitHub ↗

JacekRuzyczka

It's the method [begin() ](https://github.com/OLIMEX/FabGL/blob/04f328a10573297dd554f13be7f369cdee0f7a2b/src/devdrivers/CH32V003.cpp#L79), which provokes a Guru Meditation reproducibly: `Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.` I tried to call it from the [begin() method of terminal.cpp:](https://github.com/OLIMEX/FabGL/blob/04f328a10573297dd554f13be7f369cdee0f7a2b/src/terminal.cpp#L307) ``` bool success = (m_glyphsBuffer.map != nullptr); if (success) { reset(); success = m_mux -> begin (); // TROUBLE } return success; ``` When I remove the line with the `begin()` method call, everything works fine. Here is the stack trace. Please note that I don't understand anything displayed here due to lack of µC expertise: ``` Core 1 register dump: PC : 0x400e52b5 PS : 0x00060c30 A0 : 0x800de86c A1 : 0x3ffc66a0 A2 : 0x00000000 A3 : 0x00000023 A4 : 0x00000001 A5 : 0x0000000e A6 : 0x0000000d A7 : 0x00000001 A8 : 0x0000000c A9 : 0x3ffc66d0 A10 : 0x00000001 A11 : 0x00000000 A12 : 0x00000000 A13 : 0x00000000 A14 : 0x3ffdffec A15 : 0x00000000 SAR : 0x00000018 EXCCAUSE: 0x0000001d EXCVADDR: 0x00000000 LBEG : 0x4008aad9 LEND : 0x4008aafb LCOUNT : 0xffffffff Backtrace: 0x400e52b2:0x3ffc66a0 0x400de869:0x3ffc6730 0x400d2dc6:0x3ffc6760 0x400d43a4:0x3ffc6780 0x400f362e:0x3ffc67b0 ``` I pasted the trace into the exception decoder to get this output: ``` PC: 0x400e52b5: CH32V003::begin(gpio_num_t, gpio_num_t, gpio_num_t, gpio_num_t, short, short) at /home/jacek/Arduino/libraries/OLIMEX-FABGL/src/devdrivers/CH32V003.cpp line 84 EXCVADDR: 0x00000000 Decoding stack results 0x400e52b2: CH32V003::begin(gpio_num_t, gpio_num_t, gpio_num_t, gpio_num_t, short, short) at /home/jacek/Arduino/libraries/OLIMEX-FABGL/src/devdrivers/CH32V003.cpp line 82 0x400de869: fabgl::Terminal::begin(fabgl::BaseDisplayController*, int, int, fabgl::Keyboard*) at /home/jacek/Arduino/libraries/OLIMEX-FABGL/src/terminal.cpp line 407 0x400d2dc6: ConfDialogApp::setupDisplay() at /home/jacek/Arduino/libraries/OLIMEX-FABGL/examples/VGA/AnsiTerminal/confdialog.h line 645 0x400d43a4: setup() at /home/jacek/Arduino/libraries/OLIMEX-FABGL/examples/VGA/AnsiTerminal/AnsiTerminal.ino line 108 0x400f362e: loopTask(void*) at /home/jacek/.arduino15/packages/esp32/hardware/esp32/2.0.11/cores/esp32/main.cpp line 42 ``` What's wrong here? Lack of memory?

Comments

JacekRuzyczka

I posted the issue on [https://stackoverflow.com/questions/79736886/what-does-a-guru-meditation-error-core-1-paniced-storeprohibited-on-an-esp](url) and got this response: > StoreProhibited indicated that your program tried to write to invalid memory. The EXCVADDR indicates the address that was being written to. In your case, this is 0x00000000, meaning a null pointer. In all likelihood it means that your m_mux pointer is a null pointer - you haven’t initialized it. You’ll need to construct a valid driver object first - e.g. using m_mux = new CH32V003(); - before attempting to call begin() on it. So it was the missing `new` command, which caused the crash.