0 votes

Hello, I'm trying to create a bullet hell battle mechanic in my game, and I'm creating both Areas and Shapes directly inside the Physics2DServer, which I think relates to the issue at hand. Now, for the issue:

For some reason, my game is randomly crashing while executing with the following message:

E 0:00:51.259 is_shape_set_as_disabled: FATAL: Index p_idx = 0 is out of bounds (shapes.size() = 0). <C++ Source> servers/physics_2d/collision_object_2d_sw.h:153 @ is_shape_set_as_disabled()

Which tells me that the crash comes from a bug with a collision object querying something, but I'm not sure where to go from there. Also, each time this crash happens, the game AND the editor freeze for several seconds, like what happens when the editor itself is about to crash.

I tried to run the game from the terminal as well to try to get more info on the error, and I got the following output:
handle_crash: Program crashed with signal 11 Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues [1] 1 libsystem_platform.dylib 0x00007fff6acc242d _sigtramp + 29 [2] 2 ??? 0x0000000000000000 0x0 + 0 [3] BroadPhase2DHashGrid::move(unsigned int, Rect2 const&) (in Godot) + 342 [4] CollisionObject2DSW::_update_shapes() (in Godot) + 170 [5] CollisionObject2DSW::_shape_changed() (in Godot) + 14 [6] Physics2DServerSW::free(RID) (in Godot) + 74 [7] CommandQueueMT::flush_one(bool) (in Godot) + 134 [8] Physics2DServerWrapMT::thread_loop() (in Godot) + 142 [9] ThreadPosix::thread_callback(void*) (in Godot) + 85 [10] 10 libsystem_pthread.dylib 0x00007fff6accde65 _pthread_start + 148 [11] 11 libsystem_pthread.dylib 0x00007fff6acc983b thread_start + 15

And finally: this is the core logic I'm using to create the bullets:

https://pastebin.com/qNCEy2Hw

I'm not sure what's exactly happening or how to properly debug issues with the Physics server directly, so any help would be greatly appreciated.

asked Feb 6 in Projects by Eric De Sedas (23 points)

1 Answer

0 votes

Index p_idx = 0 is out of bounds seems to be the key.

you (or the physics server) is trying to query a shape when there's nothing there.

it doesn't look like your stacktrace gives any useful hints as to where your game logic triggers this.

I think before you interact with the physics server, query to make sure your rid exists.

if that doesn't help, try logging a count of how many bullets you have alive, so you can see if this error occurs when you are getting close to zero. if it does, then when you are at zero or one bullets, log spam all your interactions with the physics server, which might help show whats causing the crash.

answered Feb 7 by Jason Swearingen (213 points)

Hi jason, thanks for the reply.

Something I noticed after submitting this question is that I had the 2d physics thread model as Multi-Threaded and, while this caused us no issue in 3.1, it appears to be related to what's happening here in 3.2.

It appears that something changed in their physics multi thread implementation when doing 3.2, or the bug was always happening in 3.1, but was not being reported (not really sure, I just know that I started getting this error in 3.2)

Right now, the game hasn't crashed since changing the thread model to "Single-Safe". I will still keep testing this to make sure it works, and will update here if anything changes.

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 How to use this Q&A? before posting your first questions.