News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

simworld: wrap karte_t::step body with intr_disable/intr_enable

Started by janry, May 20, 2026, 08:24:23 PM

Previous topic - Next topic

0 Members and 5 Guests are viewing this topic.

janry

INT_CHECK calls inside karte_t::step (during fab_list iteration in
simfab.cc, and several explicit INT_CHECK("...") sites in simworld.cc
itself) can pump GUI events while step is mid-iteration over
fab_list / convoi_array / cities. If a welt_gui_t ("New world")
dialog is open, its "Start" handler in gui/welt.cc calls
welt->init(), which runs karte_t::destroy() and frees the very
factory whose step is on the stack. ASAN reports a
heap-use-after-free in array_tpl<ware_production_t>::get_count.

The karte_t::interactive() loop calls step() with no wrap; only
modal_dialogue() in gui/simwin.cc currently guards the call with
intr_disable()/intr_enable(). Pushing the wrap into step() itself
makes the guard apply to every caller and renders the
modal_dialogue wrap redundant (harmless, can be removed in a
follow-up if desired).

prissi

Depending on map size, mouse movements without enough INT_CHECK can be very sloppy. The proper way is to do this interaction by a tool. Same needs to be done for loading/scenarios/ ....

I tried this with a very large map and it was dramatic, fps dripping to 2 while before still 7-10 were possible.

For the moment, I changed the list to numerical enumerators as ancient C which will somewhat cope with deleting factories etc. while iterating.


prissi

Something, the handling of the parameter could still be via pointers for the internal tools so heightmaps work without potentially crashing the current map when overwriting their settings during a step. I had started this already in the last commit, so thank for this, I will incorporate it.