Crash with cryptic log while running the game

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Eric De Sedas

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 [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:

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.

:bust_in_silhouette: Reply From: Jason Swearingen

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.

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.

Eric De Sedas | 2020-02-08 16:45

I was getting the what the op posted and a few other physics related error as well. especially common was ERROR: _unpair_attempt: Condition "!E" is true. At: servers/physics_2d/broad_phase_2d_hash_grid.cpp:57 switching back to “Single-Safe” resolved those errors for me as well.

dmaz | 2021-02-03 03:38

Fixed my issue, thanks so much!!

chunkyPug | 2021-02-14 19:26