News:

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

Crash when try to create a new map with big citys

Started by makie, May 10, 2026, 05:09:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

makie

R11946 -- pak128.german

Start new map, all default, but citysize 16000 edit: start is year 1900

Quote#0  stadt_t::build_city_house (this=this@entry=0x4533c690, base_pos=..., h=h@entry=0x37371510, rotation=3 '\003', cl=cl@entry=6,
    exclude_desc=exclude_desc@entry=0xb1de50 <stadt_t::renovate_city_building(gebaeude_t*)::exclude_desc>)
    at src/simutrans/world/../builder/../descriptor/building_desc.h:273
#1  0x0000000000853c10 in stadt_t::renovate_city_building (this=this@entry=0x4533c690, gb=gb@entry=0x499fb5a0) at src/simutrans/world/simcity.cc:3583
#2  0x000000000085ab70 in stadt_t::build (this=this@entry=0x4533c690) at src/simutrans/world/simcity.cc:4153
#3  0x000000000085ac8b in stadt_t::step_grow_city (this=0x4533c690, new_town=false) at src/simutrans/world/simcity.cc:1816
#4  0x000000000085ad8a in stadt_t::change_size (this=0x4533c690, delta_citizen=delta_citizen@entry=65536, new_town=<optimized out>)
    at src/simutrans/world/simcity.cc:1439
#5  0x000000000086a6fb in karte_t::distribute_cities (this=this@entry=0x4294fb30, new_city_count=20, new_mean_citizen_count=<optimized out>,
    old_x=old_x@entry=0, old_y=old_y@entry=0) at src/simutrans/world/simworld.cc:872
#6  0x000000000087efcf in karte_t::enlarge_map (this=this@entry=0x4294fb30, sets=sets@entry=0x4294fd88, h_field=h_field@entry=0x0)
    at src/simutrans/world/../world/../dataobj/settings.h:427
#7  0x000000000087fa66 in karte_t::init (this=0x4294fb30, sets=0xa3a280 <env_t::default_settings>, h_field=h_field@entry=0x0)
    at src/simutrans/world/simworld.cc:1280
#8  0x0000000000647ff6 in welt_gui_t::action_triggered (this=0x436e9cd0, comp=<optimized out>, v=...)
    at src/simutrans/gui/../dataobj/../world/simworld.h:1283
#9  0x00000000004f823b in gui_action_creator_t::call_listeners (this=0x436eb2b8, v=...) at src/simutrans/gui/components/gui_action_creator.h:32


#0  stadt_t::build_city_house (this=this@entry=0x3a36bd30, base_pos=..., h=h@entry=0x2158e930, rotation=0 '\000', cl=cl@entry=6,
    exclude_desc=exclude_desc@entry=0xb1de50 <stadt_t::renovate_city_building(gebaeude_t*)::exclude_desc>)
    at src/simutrans/world/../builder/../descriptor/building_desc.h:273
#1  0x0000000000853c10 in stadt_t::renovate_city_building (this=this@entry=0x3a36bd30, gb=gb@entry=0x3a5077a0) at src/simutrans/world/simcity.cc:3583
#2  0x000000000085ab70 in stadt_t::build (this=this@entry=0x3a36bd30) at src/simutrans/world/simcity.cc:4153
#3  0x000000000085ac8b in stadt_t::step_grow_city (this=0x3a36bd30, new_town=false) at src/simutrans/world/simcity.cc:1816
#4  0x000000000085ad8a in stadt_t::change_size (this=0x3a36bd30, delta_citizen=delta_citizen@entry=16384, new_town=<optimized out>)
    at src/simutrans/world/simcity.cc:1439
#5  0x000000000086a6fb in karte_t::distribute_cities (this=this@entry=0x2ca60470, new_city_count=175, new_mean_citizen_count=<optimized out>,
    old_x=old_x@entry=0, old_y=old_y@entry=0) at src/simutrans/world/simworld.cc:872
#6  0x000000000087efcf in karte_t::enlarge_map (this=this@entry=0x2ca60470, sets=sets@entry=0x2ca606c8, h_field=h_field@entry=0x0)
    at src/simutrans/world/../world/../dataobj/settings.h:427
#7  0x000000000087fa66 in karte_t::init (this=0x2ca60470, sets=0xa3a280 <env_t::default_settings>, h_field=h_field@entry=0x0)
    at src/simutrans/world/simworld.cc:1280
#8  0x0000000000647ff6 in welt_gui_t::action_triggered (this=0x2d7a9630, comp=<optimized out>, v=...)
    at src/simutrans/gui/../dataobj/../world/simworld.h:1283
#9  0x00000000004f823b in gui_action_creator_t::call_listeners (this=0x2d7aac18, v=...) at src/simutrans/gui/components/gui_action_creator.h:32
#10 button_t::infowin_event (this=<optimized out>, ev=<optimized out>) at src/simutrans/gui/components/gui_button.cc:311
#11 0x00000000004feaad in gui_container_t::infowin_event (this=0x2d781d00, ev=0x7ffc3083c2d0) at src/simutrans/gui/components/gui_container.cc:149


makie

*Hm*
After deleting settings.xml I cannot reproduce the crash.
I think that's settled for now.


Crash happened with the settings recommended on our website.
https://https://pak128-german.de/inc/spieltipps.html
Edit:
Happened not the first time after delete settings.xml,
but when repeat creating a new map.

It seems to me that it is due to the alpine climate.

QuoteProgram terminated with signal SIGSEGV, Segmentation fault.
#0  stadt_t::build_city_house (this=this@entry=0x27ce2d60, base_pos=..., h=h@entry=0x242d6cb0, rotation=2 '\002', cl=cl@entry=5,
    exclude_desc=exclude_desc@entry=0xb1de50 <stadt_t::renovate_city_building(gebaeude_t*)::exclude_desc>)
    at src/simutrans/world/../builder/../descriptor/building_desc.h:273
273            uint16 get_level() const { return level; }
[Current thread is 1 (Thread 0x7f35568b9940 (LWP 8067))]

Quote#0  stadt_t::build_city_house (this=this@entry=0x27ce2d60, base_pos=..., h=h@entry=0x242d6cb0, rotation=2 '\002', cl=cl@entry=5,
    exclude_desc=exclude_desc@entry=0xb1de50 <stadt_t::renovate_city_building(gebaeude_t*)::exclude_desc>)
    at src/simutrans/world/../builder/../descriptor/building_desc.h:273
#1  0x0000000000853c10 in stadt_t::renovate_city_building (this=this@entry=0x27ce2d60, gb=gb@entry=0x30e359e0) at src/simutrans/world/simcity.cc:3583
#2  0x000000000085ab70 in stadt_t::build (this=this@entry=0x27ce2d60) at src/simutrans/world/simcity.cc:4153
#3  0x000000000085ac8b in stadt_t::step_grow_city (this=0x27ce2d60, new_town=false) at src/simutrans/world/simcity.cc:1816
#4  0x000000000085ad8a in stadt_t::change_size (this=0x27ce2d60, delta_citizen=delta_citizen@entry=4096, new_town=<optimized out>)
    at src/simutrans/world/simcity.cc:1439
#5  0x000000000086a6fb in karte_t::distribute_cities (this=this@entry=0x27cabe50, new_city_count=56, new_mean_citizen_count=<optimized out>,
    old_x=old_x@entry=0, old_y=old_y@entry=0) at src/simutrans/world/simworld.cc:872
#6  0x000000000087efcf in karte_t::enlarge_map (this=this@entry=0x27cabe50, sets=sets@entry=0x27cac0a8, h_field=h_field@entry=0x0)
    at src/simutrans/world/../world/../dataobj/settings.h:427
#7  0x000000000087fa66 in karte_t::init (this=0x27cabe50, sets=0xa3a280 <env_t::default_settings>, h_field=h_field@entry=0x0)
    at src/simutrans/world/simworld.cc:1280
#8  0x0000000000647ff6 in welt_gui_t::action_triggered (this=0x30b95630, comp=<optimized out>, v=...)
    at src/simutrans/gui/../dataobj/../world/simworld.h:1283
#9  0x00000000004f823b in gui_action_creator_t::call_listeners (this=0x30b96c18, v=...) at src/simutrans/gui/components/gui_action_creator.h:32
#10 button_t::infowin_event (this=<optimized out>, ev=<optimized out>) at src/simutrans/gui/components/gui_button.cc:311
#11 0x00000000004feaad in gui_container_t::infowin_event (this=0x30bbe840, ev=0x7ffd1f5000a0) at src/simutrans/gui/components/gui_container.cc:149
#12 0x00000000004feaad in gui_container_t::infowin_event (this=0x30b96ed0, ev=ev@entry=0x7ffd1f500110)
    at src/simutrans/gui/components/gui_container.cc:149
#13 0x000000000059be9d in gui_frame_t::infowin_event (this=0x30b95630, ev=<optimized out>) at src/simutrans/gui/gui_frame.cc:134

makie

The more debugging aids I add, the less frequently the crash occurs. But when working normally, it happens often enough to be annoying.

That smells like the use of already freed memory.

It happens when renovating 2x2 buildings within the scope of this routine.
simcity.cc line about 3323

Quote// if new building is smaller than old one => convert remaining tiles
    for (int x = 0; x < min_size.x; x++) {
        for (int y = 0; y < min_size.y; y++) {
DBG_MESSAGE("stadt_t::build_city_house", "Pos x,y (%i,%i)", x,y);
            if (x < h->get_x(rotation) && y < h->get_y(rotation)) {
                continue;
            }
            koord kpos = base_pos.get_2d() + koord(x, y);
            grund_t* gr = welt->lookup_kartenboden_nocheck(kpos);
            gebaeude_t* oldgb = gr->find<gebaeude_t>();
            const building_desc_t* hr = NULL;

            switch (oldgb->get_tile()->get_desc()->get_type()) {
                case building_desc_t::city_res:
                    won -= level * 10;
                    hr = hausbauer_t::get_residential(level, welt->get_timeline_year_month(), welt->get_climate(kpos), cl, 1, 1, exclude_desc);
                    won += hr->get_level();
                    break;
                case building_desc_t::city_com:
                    arb -= level * 20;
                    hr = hausbauer_t::get_commercial(level, welt->get_timeline_year_month(), welt->get_climate(kpos), cl, 1, 1, exclude_desc);
                    arb += hr->get_level() * 20;
                    break;
                case building_desc_t::city_ind:
                    arb -= level * 20;
                    hr = hausbauer_t::get_industrial(level, welt->get_timeline_year_month(), welt->get_climate(kpos), cl, 1, 1, exclude_desc);
                    arb += hr->get_level() * 20;
                    break;

                default:
                    assert(false);
                    break;
            }
            // for now we just remove it to avoid half buildings left
            exclude_desc->append(hr);
            oldgb->set_tile(hr->get_tile(0), true);
            gr->calc_image();
            update_gebaeude_from_stadt(oldgb);
            switch (hr->get_type()) {
                case building_desc_t::city_res: won += hr->get_level() * 10; break;
                case building_desc_t::city_com: arb += hr->get_level() * 20; break;
                case building_desc_t::city_ind: arb += hr->get_level() * 20; break;
                default: break;
            }
        }
    }
It occurs regardless of whether a new map is being generated or cities are growing. It affects ordinary 2x2 houses, of which there are hundreds on the map.

There may be a connection to this error message.
https://steamcommunity.com/app/434520/discussions/0/803470345661232936/
I haven't checked whether the city population calculation is correct when a 2x2 house is renovated.
But because the routine does exactly that, I find it suspicious after all.

I didn't notice this problem during my extensive city growth tests in 2025. Something must have changed since then.
 

prissi

The problem is that hausbauer_t does not have any 1x1 building at level 1. When a larger building is replaced by smaller ones, it tries to find some different ones with the same of lower level. But pak128.german apparently does not have any res 1x1 with level 1. So it returns NULL => crash.

I will see how to fix this. Allowing higher levels somewhat defeats the purpose. SO maybe leaving tiles empty and add this level to the other tiles in the hope of getting something matching.

makie

Quote from: prissi on Yesterday at 01:19:29 PMBut pak128.german apparently does not have any res 1x1 with level 1. So it returns NULL => crash.
There are a lot of 1x1 level 1 Buildings for res, com, ind present.
All climate zones and all times.

prissi

But you need 4 different to replace a 2x2 building. SO one can run out of different buildings.

Moreover, you have buildings level 0. That was never meant to work as those will not decrease the incentive for next construction. Anyway, r12014 should no longer crash.

makie

Quote from: prissi on Yesterday at 02:14:17 PMBut you need 4 different to replace a 2x2 building. SO one can run out of different buildings.
What's wrong with building the same house three or four times? Most small levels are either settlement houses or empty plots of land.

Could this be the reason why the clusters aren't working properly? There should the same houses be located right next to each other.
QuoteMoreover, you have buildings level 0. That was never meant to work as those will not decrease the incentive for next construction. Anyway, r12014 should no longer crash.
There shouldn't be a level 0 in the current pak. At least not in res, com, ind

prissi

Not all paks have a variety of buildings. So the citybuilder tries to keep a different type of building. Unless, it is a cluster, of course. But then, clusters need the buildings across several levels or they only appear if two adjacent buildings get the same level by chance.

I definitively had buildings return zero as level when debugging. Anyway, past midnight here. will continue tomorrow.

makie

Quote from: prissi on Yesterday at 03:23:04 PMI definitively had buildings return zero as level when debugging. Anyway, past midnight here. will continue tomorrow.
Only Station "unsichtbarer_Bahnhof_fuer_Abstellgleis" has level=0, and this is a addon.
If you find more, please delete the pak-folder and reload the pak.

prissi

Every building is saved as level-1, so level 1 becomes level 0. That needs rectifying for citybuildings. More tests are needed.
EDIT: now adding again +1 on loading for citybuildings. Also foudn the error why the city size did not update correctly.

makie

Quote from: prissi on Today at 10:57:55 AMEvery building is saved as level-1, so level 1 becomes level 0. That needs rectifying for citybuildings. More tests are needed.
Ok, I was really surprised. Your list contained almost all level 1 buildings.
--------------------------------------

R12014 hasn't crashed so far despite my diligent testing. But I have not saved and reload them.