Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null pointer exception in physics server deleting floor bodies with new move and slide logic #54878

Closed
omegachysis opened this issue Nov 11, 2021 · 2 comments

Comments

@omegachysis
Copy link
Contributor

Godot version

3.4.stable

System information

Pop!_OS 21.04, NVIDIA Corporation GK104 [GeForce GTX 770], GLES3

Issue description

Using the new move_and_slide_with_snap logic results in null pointer exceptions when a floor body is freed while a kinematic body is colliding with it.

ERROR: Condition "!body" is true. Returned: nullptr
   at: body_get_direct_state (modules/bullet/bullet_physics_server.cpp:855)
ERROR: Condition "!id_map.has(p_rid.get_data())" is true. Returned: nullptr
   at: get (./core/rid.h:140)

I believe this is because of the check here:

if (on_floor && on_floor_body.is_valid()) {
// This approach makes sure there is less delay between the actual body velocity and the one we saved.
PhysicsDirectBodyState *bs = PhysicsServer::get_singleton()->body_get_direct_state(on_floor_body);

If the object on_floor_body points to is freed, the RID doesn't exist (but remains 'valid' in the kinematic body).

Steps to reproduce

  1. Create static body and a kinematic body.
  2. Make kinematic body collide with static body and sit on it as a floor.
  3. Call move_and_slide every physics tick and free the static body.

Minimal reproduction project

platform-deletion.zip

@arkology
Copy link
Contributor

arkology commented Nov 11, 2021

I'm almost sure this is definitely a duplicate of already existing issue and has already been fixed.
Upd: Duplicate of #54666

@omegachysis
Copy link
Contributor Author

omegachysis commented Nov 11, 2021

#54666 I see it now, I must have filtered by open issues by accident. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants