_lv_event_mark_deleted crashes sometimes

Description

Hi,
i build a c++ Applicaion with a lvgl GUI, which shows me errors and data of devices. The Data and Errors are received over a messageBus. An sometimes i close a MessageBox the Application crashes in _lv_event_mark_deleted Function.

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

I use the SDL Simulator on a Ubuntu 20.04 VirtualMachine and a i.MX 6 board with the GCC-Compiler.

What LVGL version are you using?

Tried with 8.0, 8.2 and 8.3.

What do you want to achieve?

I would like to Show a MessageBox every Time an Error occurs from the messageBus. This is works fine.

If the Error disapears (event from the messageBus) the MessageBox should be closed. Here is the Problem. Sometimes, when the MessageBox is closed, my Application crashes in the _lv_event_mark_deleted Function.

What have you tried so far?

I tried to use different widgets

  • the lv_msgbox (modal / non Modal)
  • self created MessageBox based on lv_obj

I tried to use different screens and different layers (top/sys layer)
I tried to use lv_obj_del_async and lv_obj_del

I tried to debug with enabling the Log-Messages (LV_LOG_...)

Code to reproduce

I wrote a Wrapper Class for all lv_obj that were created. This class has an destroy Method to delete the lvgl object. I use the lv_obj_is_valid Method to check, that a Object is valid to delete.

The Method shows the synchron way for the Deletion. In this case the code crashes in the line with lv_obj_del(m_widget);

void BaseLvglWidget::destroyLvWidget()
{
    if(m_widget and (not m_isDeleted) and lv_obj_is_valid(m_widget))
    {
        m_isEnabled = false; // Block Signal publishs
        m_isDeleted = true;   // Avoid using the Object after Deletion
        lv_obj_del(m_widget);
    }
}

In the Async Method the Crash is during the run of the lv_timer_handler

Screenshot and/or video


Can someone help me or guide me in the right direction to solve the Problem?

Is the application multi thread? If so use mutex to make sure your not changing anything when lv task handler runs

1 Like

I got basically the same issue. It occurs rather randomly.

Hi, yes the Applikation is multi threaded. I will try tomorrow to use a mutex.
Thanks for your reply.

That worked for me. Great.
Thank you very much !!