Systematic hardfault in lv_group_get_focused


Hello. I’m using LVGL v8.0 in FreeRTOS and I’v been struggling with this hardfault for some days.
It happens in function lv_group_get_focused on its return statement since the content
of group variable has been corrupted by lvgl itself, in particular, by calling the function
I have a task for the lv_task_handler called every 10ms and the function lv_tick_inc hooked to the FreeRTOS system tick handler which is called every 1ms. And I obviousl have the lvgl_task where I call all the above mentioned function. No lvgl functions are called in any other tasks.

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

I’m using a custom board based on i.MXRT1052 MCU.

What LVGL version are you using?


What do you want to achieve?

I was trying to create a message box, but the hardfault appears on other code, described above.

What have you tried so far?

I have tried to avoid freeing some resources of mine and also placed a conditional breakpoint in the vPortFree function of FreeRTOS which manages the memory, to see if someone frees the same address in memory, but it doesn’t get hit before the hardfault.

Code to reproduce

Well, it’s quite complex to post code here. It involves a couple of FreeRTOS tasks and a whole custom messaging system based on it.

Screenshot and/or video

Here are some screenshot of the memory and variables (IAR IDE).

This is the content of memory when I populate my string to be whown in the message box.

Then I free it because I copied it to another place.

Later it is used by the label that I use to show the free heap memory with this function call

void UpdateLabels(lv_obj_t * screen)
HeapStats_t xHeapStats;
vPortGetHeapStats( &xHeapStats );

lv_label_set_text_fmt(label_heap, “System free: %d kiB”, xHeapStats.xAvailableHeapSpaceInBytes/1024);

here is the memory after calling the above function

As you can see the address is the same as above, 0x200287c0.

If I run the program here i get the hardfault. Here are the details:

Call stack

Local variables
As you can see the memory used is the one used by the previous call to lv_label_set_text_fmt.
In red are the values that can be seen in the next picture…

The content of that memory is always the same, but that’s not good for this scope:

Am I missing something?

Well, I’m leaving for vacation and bringing this problem with me :smiley: I hope I can at least read any replies to this topic.

Best regards,

Any thoughts on this?

My bad. I found out was freeing a pointer not allocated sometimes. Sorry.