_lv_event_mark_deleted call leads to crash (ESP32)


First, I would like to express my sincere gratitude to all the great people working on LVGL. I have been using the library for some time now and it is amazing!

Now, I would like to ask for your help with an issue.

I have been experiencing somewhat random and infrequent crashes in my app when calling lv_obj_clean(lv_scr_act()). The crash happens when calling _lv_event_mark_deleted (event_head seems to be dangling). My understanding is that this problem can occur when incorrectly calling lv_ functions in a multithreaded environment. However, all my LVGL logic is located in one FreeRTOS task. Well… most of it. I noticed a call to lv_disp_trig_activity(NULL) outside my LVGL logic task. Could that be the source of the problem? Could it be a completely different reason? I apologize for providing so little code to reproduce the bug. The code works fine 99% of the time but sometimes crashes at different places but always when trying to clean the default screen with lv_obj_clean(lv_scr_act()). I included an example of a backtrace below (see Screenshot and/or video). By analyzing the trace, I can see that the ESP32 hangs when trying to access a variable at a improper location (excvaddr: 0x5844). Could the issue be ESP32 specific?

Thank you for your help!!

Related issues:

What MCU/Processor/Board and compiler are you using?

ESP32 (ESP-IDF v5.0.2)

What LVGL version are you using?


What do you want to achieve?

Clean default screen.

What have you tried so far?

Locate LVGL function calls outside main LVGL logic task. Analyze coredump.

Code to reproduce

lv_group_set_editing(lv_group_get_default(), false);
lv_obj_clean(lv_scr_act()); //< cause of crash

Screenshot and/or video

================== CURRENT THREAD REGISTERS ===================
exccause 0x1c (LoadProhibitedCause)
excvaddr 0x5844
epc1 0x400dbf0b
epc2 0x0
epc3 0x0
epc4 0x0
epc5 0x40089db1
epc6 0x0
eps2 0x0
eps3 0x0
eps4 0x0
eps5 0x60120
eps6 0x0
pc 0x400ff69a 0x400ff69a <_lv_event_mark_deleted+14>
lbeg 0x4010798d 1074821517
lend 0x40107994 1074821524
lcount 0x1 1
sar 0x1b 27
ps 0x60b20 396064
a0 0x80102108 -2146426616
a1 0x3ffe2320 1073619744
a2 0x3ffc7af4 1073511156
a3 0x3ffe2370 1073619824
a4 0x15 21
a5 0x13f 319
a6 0x80000001 -2147483647
a7 0x0 0
a8 0x5840 22592
a9 0x800e1729 -2146560215
a10 0x1 1
a11 0x17548 95560
a12 0x144 324
a13 0xfffffffb -5
a14 0xfffffffb -5
a15 0x1 1
==================== CURRENT THREAD STACK =====================
#0 _lv_event_mark_deleted (obj=0x3ffc7af4) at …/components/lvgl/src/core/lv_event.c:157
#1 0x40102108 in lv_obj_destructor (class_p=0x3f5ebcd8 <lv_obj_class>, obj=0x3ffc7af4) at …/components/lvgl/src/core/lv_obj.c:435
#2 0x401bc43c in _lv_obj_destruct (obj=0x3ffc7af4) at …/components/lvgl/src/core/lv_obj_class.c:136
#3 0x40107a11 in obj_del_core (obj=0x3ffc7af4) at …/components/lvgl/src/core/lv_obj_tree.c:389
#4 0x40107b3e in obj_del_core (obj=0x3ffc7af4) at …/components/lvgl/src/core/lv_obj_tree.c:361
#5 lv_obj_clean (obj=0x3fff1cb4) at …/components/lvgl/src/core/lv_obj_tree.c:94