URL:
<http://gna.org/bugs/?18087>
Summary: server segfault on a map with 1.3M tiles
Project: Freeciv
Submitted by: akfaew
Submitted on: Sat 30 Apr 2011 01:29:31 PM GMT
Category: None
Severity: 3 - Normal
Priority: 5 - Normal
Status: None
Assigned to: None
Originator Email:
Open/Closed: Open
Release:
Discussion Lock: Any
Operating System: None
Planned Release:
_______________________________________________________
Details:
I increased the map size:
-#define MAP_MAX_LINEAR_SIZE 512
+#define MAP_MAX_LINEAR_SIZE 2048
But am getting a segfault. gdb tells me it's assign_continent_flood which
recurses so deeply it exceeds the stack, which in FreeBSD is rather big: 64MB
(in OpenBSD the default is 4MB, in SunOS 8MB, debian 8MB, ubuntu 8MB). Below
is the function that crashes (with 1.3M tiles on an earth map you have like
.7M tiles of ocean). Attached is a patch, barely tested but at least the
server starts.
275
/**************************************************************************
276 Number this tile and nearby tiles (recursively) with the specified
277 continent number nr, using a flood-fill algorithm.
278
279 is_land tells us whether we are assigning continent numbers or
ocean
280 numbers.
281
**************************************************************************/
282 static void assign_continent_flood(struct tile *ptile, bool is_land,
int nr)
283 {
284 const struct terrain *pterrain = tile_terrain(ptile);
285
286 if (tile_continent(ptile) != 0) {
287 return;
288 }
289
290 if (T_UNKNOWN == pterrain) {
291 return;
292 }
293
294 if (!XOR(is_land, terrain_has_flag(pterrain, TER_OCEANIC))) {
295 return;
296 }
297
298 tile_set_continent(ptile, nr);
299
300 /* count the tile */
301 if (nr < 0) {
302 ocean_sizes[-nr]++;
303 } else {
304 continent_sizes[nr]++;
305 }
306
307 adjc_iterate(ptile, tile1) {
308 assign_continent_flood(tile1, is_land, nr);
309 } adjc_iterate_end;
310 }
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Sat 30 Apr 2011 01:29:31 PM GMT Name: iterative.diff Size: 2kB By:
akfaew
<http://gna.org/bugs/download.php?file_id=12931>
_______________________________________________________
Reply to this item at:
<http://gna.org/bugs/?18087>
_______________________________________________
Message sent via/by Gna!
http://gna.org/
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev