whitecatboard / Lua-RTOS-ESP32

Lua RTOS for ESP32
Other
1.2k stars 221 forks source link

Core1 panic'ed StoreProhibited #204

Closed gjongenelen closed 5 years ago

gjongenelen commented 5 years ago

I'm getting random panics when reading data via UART.

screenshot 2018-10-25 at 17 00 10

How can I debug this?

jolivepetrus commented 5 years ago

@gjongenelen,

Please, proceed as follows:

make clean make upgrade-idf make

gjongenelen commented 5 years ago

Did that several times, but without any success. I found out that it is the el/l-argument which is causing the issue.

uart.read(uart.UART1, "*el", 1000); -- StoreProhibited
uart.read(uart.UART1, "*l", 1000); -- StoreProhibited
uart.read(uart.UART1, "*c", 1000); -- No problems (so far)

I guess it has something to do with the buffer(?) in: https://github.com/whitecatboard/Lua-RTOS-ESP32/blob/449517900a2ee4167628fc4f8547ce240e9de23d/components/lua/modules/hw/uart.c#L275

Important notice: The serial connection is mostly quiet. So it may happen that there are 30 timeouts before something enters the RX-line. (This is easy to reproduced by grabbing an ESP32, attaching UART without anything physically connected and reading constantly with timeout of 1000ms ex.)

the0ne commented 5 years ago

@gjongenelen you should make sure that str is not null after malloc, before using it in line 278.

https://github.com/whitecatboard/Lua-RTOS-ESP32/blob/449517900a2ee4167628fc4f8547ce240e9de23d/components/lua/modules/hw/uart.c#L275-L278

the0ne commented 5 years ago

fixed in 9e61e52725c4b77574e9bf9261a96f918ab779f5 as it currently only is in my fork and the PR #184 you may want to cherry-pick it.

jolivepetrus commented 5 years ago

@gjongenelen, @the0ne,

Merged in https://github.com/whitecatboard/Lua-RTOS-ESP32/commit/2b98d995192cc448af0499957635c5abbe8e4dea.