Context: Our game has a lot of enemies on screen (think of Vampire Survivors), so there's a lot area2Ds / Kinematic Bodies with collisions colliding with each other.
The crash happens with the following steps:
- Spawn a bunch of enemies
- Kill them with an AOE spell (not sure if this is the problem or it just increases chances for the crash since it kills more faster)
- Eventually (it can take less than a minute or 15) the game will crash leaving the following report in the logs (p_index can change it's value between crashes):
ERROR: FATAL: Index p_index = 4 is out of bounds (count = 0). at: operator (./core/local_vector.h:181) - FATAL: Index p_index = 4 is out of bounds (count = 0).
We actually managed to reproduce this Fatal error in a new project, and posted an issue about it. But a new problem has arised: we tried backing to 3.4 since in the issue we found out it doesn't occur in 3.4, this version of the game is really bugged, since it was a quick test all the Scene Unique Nodes and Tween changes between 3.4 and 3.5 were just commented (i'm saying this in the offchance that all the errors related to commenting those parts of the code may be causing the crash in 3.4). In this version we started trying the crash again, it was hard but we found it again (and this time the console log displayed the error instead of the file hidden in %appdata%)
So now there's a new problem, in the issue we found out freeing large quantities of colliding Area2Ds crashes the game, if instead of freeing we just disable / stop monitoring then the small test we made doesn't crash. Then why does it happen in our big project?
To recreate this disable / monitoring off behaviour efficiently we started pooling the enemies, but it still crashes. So now we can't really know what the problem is, it may be a combination of nodes colliding and then stop colliding, it may be a caching problem, it may be a file corrupted.
With all this, we would like to know: What does local_vector.h do? and what does it have to do with Area2Ds / KinematicBodies / CollisionBoxes? if anyone knows please tell us.