Skip to content

Crash in jolt physics when disabling a soft body #108030

Closed
@simpkins

Description

@simpkins

Tested versions

  • Reproducible in 4.5-beta1
  • I wasn't able to reproduce in 4.4, although the buggy code appears to be in that version as well. I didn't spend too long investigating, though.

System information

Windows 11

Issue description

If a SoftBody3D object is disabled, its default behavior is to remove itself from the physics server by calling PhysicsServer3D::soft_body_set_mesh() to reset the mesh to an empty RID.

With the Jolt physics server, this causes a crash, here:

jolt_settings->mPressure = pressure;

The JoltSoftBody3D code generally assumes that the jolt_settings member variable is null when the body is actively part of a space (when in_space() returns true), and non-null when the body is not part of a space. However, calling JoltSoftBody3D::set_mesh() with a null RID moves the body out of the space, but does not re-allocate the jolt_settings member variable. This causes a crash when the code tries to access it later in the set_mesh() call (inside _space_changed()).

Steps to reproduce

Use gdscript to run soft_body.process_mode = Node.PROCESS_MODE_DISABLED with a SoftBody3D object.
See the attached MRP.

Minimal reproduction project (MRP)

soft_body_jolt_crash.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Release Blocker

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions