# Map generation crash while underground (backtrace)

**URL:** <https://discourse.cataclysmdda.org/t/map-generation-crash-while-underground-backtrace/382>\
**Category:** The Garage\
**Created:** [March 8, 2013, 4:29am UTC](https://discourse.cataclysmdda.org/t/map-generation-crash-while-underground-backtrace/382 "2013-03-08T04:29:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mathieu](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@mathieu](https://discourse.cataclysmdda.org/u/mathieu)\
**Post date:** [March 8, 2013, 4:29am UTC](https://discourse.cataclysmdda.org/t/map-generation-crash-while-underground-backtrace/382/1 "2013-03-08T04:29:01Z")

</div>

Hi. I got lost in a giant underground science lab; while wandering it’ll eventually crash. I’m at revision 284d56f187f1694e5f6458a0c3182625997d1572.

```auto
Program received signal SIGSEGV, Segmentation fault.
0x08311295 in map::generate (this=0xbfbc0ae4, g=0x29701000, om=0x2970415c, 
    x=210, y=292, turn=112212) at mapgen.cpp:198
198 float size = (float)closest_city->s;
(gdb) bt
#0 0x08311295 in map::generate (this=0xbfbc0ae4, g=0x29701000, om=0x2970415c, 
    x=210, y=292, turn=112212) at mapgen.cpp:198
#1 0x08bbcfd9 in map::loadn (this=0x2972ba94, g=0x29701000, worldx=210, 
    worldy=282, gridx=0, gridy=10, update_vehicles=true) at map.cpp:3093
#2 0x08bbd1ba in map::shift (this=0x2972ba94, g=0x29701000, wx=210, wy=281, 
    sx=0, sy=1) at map.cpp:2947
#3 0x08839002 in game::update_map (this=0x29701000, x=@0xbfbfde04, 
    y=@0xbfbfde08) at game.cpp:7943
#4 0x0883c788 in game::plmove (this=0x29701000, x=60, y=60) at game.cpp:7493
#5 0x0885a2c3 in game::handle_action (this=0x29701000) at game.cpp:1464
#6 0x0885f9b5 in game::do_turn (this=0x29701000) at game.cpp:679
#7 0x089f642b in main (argc=0, argv=0xbfbfe43c) at main.cpp:70
(gdb) f 0
#0 0x08311295 in map::generate (this=0xbfbc0ae4, g=0x29701000, om=0x2970415c, 
    x=210, y=292, turn=112212) at mapgen.cpp:198
198 float size = (float)closest_city->s;
(gdb) list
193 }
194     
195 // This attempts to scale density of zombies inversely with distance from the nearest city.
196 // In other words, make city centers dense and perimiters sparse.
197 city *closest_city = &om->cities[om->closest_city(point(overx, overy))];
198 float size = (float)closest_city->s;
199 float dist = (float)rl_dist(overx, overy, closest_city->x, closest_city->y);
200 float density = log(1 + (size - dist) / size);
201 draw_map(terrain_type, t_north, t_east, t_south, t_west, t_above, turn, g, density);
202     
(gdb) p closest_city
$1 = (city *) 0xfffffff4
```

Then I checked a bit more… the om-\>cities vector is empty (not supposed to I guess?) and overmap::closest\_city() must have returned -1… No idea how to fix it.

---

<div class="post-metadata">

**Author:** ![Thuztor](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/thuztor/32/22_2.png) [@Thuztor](https://discourse.cataclysmdda.org/u/Thuztor)\
**Post date:** [March 10, 2013, 9:33pm UTC](https://discourse.cataclysmdda.org/t/map-generation-crash-while-underground-backtrace/382/2 "2013-03-10T21:33:37Z")

</div>

I have the same issue.  
I saved in a science lab and after loading, the game crashes randomly while I walked around.

v.0.2

---

<div class="post-metadata">

**Author:** ![Pawel1997PL](https://avatars.discourse-cdn.com/v4/letter/p/f0a364/32.png) [@Pawel1997PL](https://discourse.cataclysmdda.org/u/Pawel1997PL)\
**Post date:** [March 12, 2013, 4:05pm UTC](https://discourse.cataclysmdda.org/t/map-generation-crash-while-underground-backtrace/382/3 "2013-03-12T16:05:43Z")

</div>

I think I have the same problem, whenever I savescum underground, it only lets me walk around areas that I’ve already been to, if I try to explore it crashes. Going up a z level seems to fix this
