News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

Headless gui_schedule_t crashes when no GUI theme is loaded

Started by victor_18993, August 02, 2026, 02:43:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

victor_18993

This was found while rebasing and running the automated tests for the schedule route overlay discussed here:

https://forum.simutrans.com/index.php/topic,24000.0.html

It is separate from the overlay itself, so I am opening a different thread rather than mixing a possible headless GUI issue into that patch.

In a headless build, Simutrans intentionally does not load a GUI theme. The fallback to the default theme and the fatal error for a missing theme are both inside:

#if COLOUR_DEPTH != 0

Therefore, with COLOUR_DEPTH == 0, skinverwaltung_t::gadget may legitimately remain NULL.

The official automated test suite does not normally expose a problem because it does not construct gui_schedule_t. The overlay tests do, and without an explicit theme they reach this access in gui_schedule.cc:

del.set_image(skinverwaltung_t::gadget->get_image_id(2));

Since skinverwaltung_t::gadget is NULL, the process ends with a SIGSEGV before the test framework can report a result.

Using:

-theme classic.tab

makes the same tests pass. classic.tab and classic.pak are already included in the source tree.

I have confirmed the following:

- the normal headless suite runs successfully without a theme;
- the crash only becomes reachable when gui_schedule_t is constructed;
- four other uses of skinverwaltung_t::gadget in simwin.cc and gui_theme.cc check for NULL;
- gui_schedule.cc and gui_flowtext.cc do not;
- the gui_schedule.cc access was introduced in 2021 with the graphical delete button.

So I am not claiming that the normal headless runner is broken. At present, any headless test that constructs GUI code must load a theme explicitly.

The question is whether gui_schedule_t should also tolerate a missing Gadget descriptor, as the other guarded call sites do, or whether loading a theme should remain a strict precondition for constructing that GUI.

I have not attached a patch because simply skipping set_image() may not be the correct product behaviour: the intended state of the delete button without a theme should be decided first.

For the overlay tests I will document -theme classic.tab as a required argument. I can also prepare a minimal independent reproduction or test possible behaviours here if that would be useful.
En la vida todo son vivencias y cada una de ellas nos hace mas grandes,¿Como de grande eres tu? :)

prissi

Since a headless build does not show anything, I think that the headless build is ok to fail on opening gui windows.

The headless builds are used for servers which should be able to run on virtual servers with minimal memory (my pak64 server runs on a 1GB 20 GB hardisk 1 core virtual machine which also hosts the german forum.) So 3EUR hosting ... Hence, the memory overhead from loading themes and images, I would rather avoid.