Odd transient issue in 8.3

Description

So one of two things is happening (About 50-75% of the time, the other times it works fine). After 2 days of playing around, I have isolated it to creating a window widget. It seems like there is some sort of race condition between the theme getting fully setup and the rest of the code running… This lead me to my AHAH moment (At least a work around, see end).

Some config items:

  1. I am using Dark Theme
  2. I have memory monitor and FPS monitor running

Seg Fault Potential #1 (Happens about 80% of the errors)

Here is the call stack:

The error is on this line

if((obj->styles[i].style->has_group & group) == 0) continue;

has_group==129 and group == 1 (I am guessing this is invalid data)

Here is the code that creates the window (Pretty standard stuff)

uint windowHeader = lv_font_default()->line_height + 2;
	if (!options.GetWindowHeader() && Label.size() == 0)
		windowHeader = 0;
	treeViewWindow = lv_win_create(parent, windowHeader);
	if (Label.size() > 0)
		lv_win_add_title(treeViewWindow, Label.c_str());

Seg Fault Potential #2

Seems to have disappeared, I cant get it to happen.

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

Raspberry PI4, GCC

What LVGL version are you using?

8.3, updated yesterday

What do you want to achieve?

No random crashed :slight_smile:

What have you tried so far?

Ive tried a lot of things to try to get this to quit happening, it took many hours to isolate because the issue kept cropping up deep in LVGL, and of course doesnt always happen.

Code to reproduce

This is hard, beyond what I have sent above. Its in a lot of other code.

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

AH HA moment

Here is my test initalizer:

if (init)
		return;
	init = true;
	std::cout << "Initalizing UI\n";
	lv_init();
	fbdev_init();
	
	lv_disp_draw_buf_init(&disp_buf, &buf, NULL, DISP_BUF_SIZE);
	lv_disp_drv_init(&disp_drv);
	disp_drv.draw_buf = &disp_buf;
	disp_drv.flush_cb = fbdev_flush;
	disp_drv.hor_res = WIDTH;
	disp_drv.ver_res = HEIGHT;
	lv_disp_drv_register(&disp_drv);

	evdev_init();
	lv_indev_drv_init(&indev_drv);
	indev_drv.type = LV_INDEV_TYPE_POINTER;

	/*This function will be called periodically (by the library) to get the mouse position and state*/
	indev_drv.read_cb = evdev_read;
	lv_indev_drv_register(&indev_drv);
	runner = new std::thread([this]{tickThread(); });
	std::this_thread::sleep_for(std::chrono::seconds(1));

Adding the last line, sleep for 1 second seems to have solved the issue, but that would lead me further down the path (Potentially rabbit trail) that the issue is somewhere in the intialization of LVGL

Further more, I am wondering if the issue with initalization is further made problematic with the addition of more logging, mem and fps monitors. Just a guess.