The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

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.

Godot version 3.5.1
in Engine by (15 points)

Also running into this issue. I managed to remove most area 2Ds that I believe were the cause, but this really needs a fix.

I think we might have fixed it, we used set_deferred to disable / stop monitoring for every Area2D / CollisionBox before freeing them and it looks like this avoids the issue, we are still testing it but it hasn't crashed yet.

Thanks for the heads up. I've also done some looking into this and I tend to hit it when area2ds are being spawned while doing a shape query. It is fairly inconsistent during normal play, but I've managed solid repros in some testbeds spawning hundreds of area2ds during a check.

I can find a workaround for now, but I'll have to basically write my own overlap checking scripts until its fixed for real.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.