Opened 2 years ago

Last modified 2 years ago

#4563 new defect

Crash if the random map script tries to spawn way too many entities

Reported by: elexis Owned by:
Priority: Nice to Have Milestone: Backlog
Component: Core engine Keywords:
Cc: Patch:

Description

As discovered in https://code.wildfiregames.com/D362 we get a crash if a random map generation tries to place too many entities in a small area:

arena.h(150): Assertion failed: "0 && (L"DynamicArena cannot allocate more than chunk size")"
Assertion failed: "0 && (L"DynamicArena cannot allocate more than chunk size")"
Location: arena.h:150 (allocate)

In that map the reeds call produced that error stack when moving the camera around in atlas:

log("Creating reeds...");
createObjectGroups(
	new SimpleGroup(
		[
			new SimpleObject(aReeds, 30, 60, 0, 4),
			new SimpleObject(aReeds2, 30, 60, 0, 4),
			new SimpleObject(aLillies, 20, 40, 0, 4)
		],
		true),
	0,
	stayClasses(clWater, 1),
	scaleByMapSize(400, 2000),
	100
);
RMS.SetProgress(40);

A similar error is reproducible with Cantabrian Highlands:

ComponentManager.cpp(824): Assertion failed: "m_ComponentCaches.find(ent) == m_ComponentCaches.end()"
Assertion failed: "m_ComponentCaches.find(ent) == m_ComponentCaches.end()"
Location: ComponentManager.cpp:824 (AllocateEntityHandle)
Index: binaries/data/mods/public/maps/random/cantabrian_highlands.js
===================================================================
--- binaries/data/mods/public/maps/random/cantabrian_highlands.js	(revision 19539)
+++ binaries/data/mods/public/maps/random/cantabrian_highlands.js	(working copy)
@@ -207,11 +207,11 @@
 
 log("Creating reeds...");
 group = new SimpleGroup(
-	[new SimpleObject(aReeds, 5,10, 0,4), new SimpleObject(aLillies, 0,1, 0,4)], true
+	[new SimpleObject(aReeds, 30,60, 0,4), new SimpleObject(aLillies, 30,60, 0,4)], true
 );
 createObjectGroupsByAreas(group, 0,
-	[borderClasses(clWater, 3, 0), stayClasses(clWater, 1)],
-	numLakes, 100,
+	[stayClasses(clWater, 1)],
+	scaleByMapSize(400, 2000), 1000,
 	waterAreas
 );
 RMS.SetProgress(20);

So RMS shouldn't do stupid things, but it would also be nice if there were some sanity checks to not crash in that case.

Change History (1)

comment:1 Changed 2 years ago by elexis

Vladislav couldn't reproduce the reeds crash on windows. The limit might be different depending on the OS

Note: See TracTickets for help on using tickets.