#4808·bullet3

removeBody leaves rigid-body constraints pointing at the deleted body

Author: peachtree0222Created Sep 15, 2026Updated Sep 15, 2026

Environment

  • OS: Ubuntu 24.04.5 LTS, Linux 7.0.0-28-generic x86_64
  • Compiler: GCC 11.5.0
  • Python: 3.12.3
  • Source: bulletphysics/bullet3 master at 63c4d67e337017f9d8b298c900e9aabdb69296e7
  • PyBullet: built locally from that exact checkout

Description

Removing a maximal-coordinate rigid body does not remove btTypedConstraint objects or m_userConstraints entries that reference it. The multibody branch performs this cleanup, but the rigid-body branch deletes the body after a //todo: clear all other remaining data... comment.

Expected behavior: removeBody removes constraints whose endpoint is the removed body, just as the multibody path does.

Actual behavior: stepping immediately after removal exits with status 139. If a replacement rigid body is allocated first, the retained fixed constraint silently binds the replacement: a body created at x=5 moves to x=4.5 and its peer moves from x=1 to x=1.5. Removing the constraint before the body is a clean control and leaves both positions unchanged.

Source: https://github.com/bulletphysics/bullet3/blob/63c4d67e337017f9d8b298c900e9aabdb69296e7/examples/SharedMemory/PhysicsServerCommandProcessor.cpp#L12739-L12848

Reproduction package:

rigid-body-removal-constraint-cleanup-poc.zip

Steps to reproduce

  1. Build PyBullet from the commit above using poc/README.md.
  2. Run the control, dangling, and reuse modes in separate processes.
  3. Compare the exit statuses, constraint counts, and positions with poc/observed-output.txt.