News:

The Forum Rules and Guidelines
Our forum has Rules and Guidelines. Please, be kind and read them ;).

crash with broken factories

Started by Dwachs, May 10, 2013, 04:23:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dwachs

Quote from: kierongreen on May 10, 2013, 03:48:03 AM
Edit:
Seems like that crash wasn't related to double heights as it also happens on trunk 6501 without patch applied. It's actually related to a missing factory pak (in the old pak128.Britain) and the new non-rectangular factory code. If a pak is missing then besch doesn't exist, therefore no valid building is returned for any of the factory coordinates, therefore trying to return the position of the building gives a segmentation fault.
Where does it crash? I could not reproduce this...
Parsley, sage, rosemary, and maggikraut.

kierongreen


Program received signal SIGSEGV, Segmentation fault.
0x0805d605 in ding_t::get_pos (this=0x0) at bauer/../besch/../dings/../simdings.h:293
293 inline koord3d get_pos() const {return pos;}

#0  0x0805d605 in ding_t::get_pos (this=0x0) at bauer/../besch/../dings/../simdings.h:293
#1  0x0824b892 in fabrik_t::baue (this=0x25b20ec8, rotate=0, build_fields=false, force_initial_prodbase=false) at simfab.cc:763
#2  0x0824ae25 in fabrik_t::fabrik_t (this=0x25b20ec8, wl=0x116eaab8, file=0xbfffce04) at simfab.cc:648
#3  0x082cb78c in karte_t::load (this=0x116eaab8, file=0xbfffce04) at simworld.cc:5517
#4  0x082c9bdf in karte_t::load (this=0x116eaab8, filename=0x9e1cf88 "save/britain1890.sve") at simworld.cc:5112
#5  0x0815429e in loadsave_frame_t::action (this=0x11828680, filename=0x9e1cf88 "save/britain1890.sve") at gui/loadsave_frame.cc:63
#6  0x08167c48 in savegame_frame_t::action_triggered (this=0x11828680, komp=0xfa6b2f0) at gui/savegame_frame.cc:315
#7  0x080f609d in gui_action_creator_t::call_listeners (this=0xfa6b2f0, v=...) at gui/components/gui_action_creator.h:36
#8  0x080f4e53 in button_t::infowin_event (this=0xfa6b2e0, ev=0xbfffd5ac) at gui/components/gui_button.cc:441
#9  0x08135355 in gui_container_t::infowin_event (this=0x11828fc4, ev=0xbfffd680) at gui/gui_container.cc:175
#10 0x081010b2 in gui_scrollpane_t::infowin_event (this=0x11828fe8, ev=0xbfffd70c) at gui/components/gui_scrollpane.cc:112
#11 0x08135355 in gui_container_t::infowin_event (this=0x11828684, ev=0xbfffd7e4) at gui/gui_container.cc:175
#12 0x08136925 in gui_frame_t::infowin_event (this=0x11828680, ev=0xbfffd86c) at gui/gui_frame.cc:125
#13 0x08168452 in savegame_frame_t::infowin_event (this=0x11828680, ev=0xbfffd86c) at gui/savegame_frame.cc:415
#14 0x082b0c36 in check_pos_win (ev=0xbfffd934) at simwin.cc:1353
#15 0x082d0777 in karte_t::interactive (this=0x116eaab8, quit_month=2147483647) at simworld.cc:6845
#16 0x0827c079 in simu_main (argc=1, argv=0xbffff674) at simmain.cc:1176
#17 0x08289ec0 in sysmain (argc=1, argv=0xbffff674) at simsys.cc:703
#18 0x082f3a24 in main (argc=1, argv=0xbffff674) at simsys_s.cc:715


The problem is in simfab:

758 void fabrik_t::baue(sint32 rotate, bool build_fields, bool force_initial_prodbase)
759 {
760 this->rotate = rotate;
761 pos_origin = welt->lookup_kartenboden(pos_origin.get_2d())->get_pos();
762 gebaeude_t *gb = hausbauer_t::baue(welt, besitzer_p, pos_origin, rotate, besch->get_haus(), this);
763 pos = gb->get_pos();
764 pos_origin.z = pos.z;
765
766 if(besch->get_field_group()) {
767 // if there are fields

hausbauer_t::baue returns null, hence gb->get_pos() gives a segmentation fault. It returns null because in

gebaeude_t* hausbauer_t::baue(karte_t* welt, spieler_t* sp, koord3d pos, int org_layout, const haus_besch_t* besch, void* param)
{
gebaeude_t* first_building = NULL;
...
for(k.y = 0; k.y < dim.y; k.y ++) {
for(k.x = 0; k.x < dim.x; k.x ++) {
//DBG_DEBUG("hausbauer_t::baue()","get_tile() at %i,%i",k.x,k.y);
const haus_tile_besch_t *tile = besch->get_tile(layout, k.x, k.y);
// here test for good tile
if (tile == NULL || (
besch->get_utyp() != haus_besch_t::hafen &&
tile->get_hintergrund(0, 0, 0) == IMG_LEER &&
tile->get_vordergrund(0, 0)    == IMG_LEER
)) {
// may have a rotation, that is not recoverable
DBG_MESSAGE("hausbauer_t::baue()","get_tile() empty at %i,%i",k.x,k.y);
continue;
}
gebaeude_t *gb = new gebaeude_t(welt, pos + k, sp, tile);
if (first_building == NULL) {
first_building = gb;
}
...
return first_building;
}

where no tiles exists in a besch first_building is never set.

Dwachs

Can you upload the pak that breaks this code? It seems to be a factory pak, which is broken to some extend: the besch is found, but it has no tiles defined ???
Parsley, sage, rosemary, and maggikraut.

kierongreen

I think this is the pak (it's from the current debian release of pak128.Britain). Whatever the problem is I don't get the problem on my own versions of pak128.Britain.

Ters

As far as I can see, there are tiles, but no images for layout 0.