pymunk
pymunk copied to clipboard
Segmentation fault when setting `body_type` to dynamic
Setting a body's body_type
to Body.DYNAMIC
causes a Segmentation fault (core dumped)
under the following conditions:
- A
SlideJoint
is attached to the body. Other types of joints don't seem to have a problem. - Pymunk version
>=6.7.0
. - The body type was not already dynamic to begin with.
import pymunk as pm
print('pymunk version', pm.version)
print('chipmunk version', pm.chipmunk_version)
space = pm.Space()
body = pm.Body(body_type=pm.Body.KINEMATIC)
space.add(body)
# this body type doesn't matter
other = pm.Body(body_type=pm.Body.KINEMATIC)
joint = pm.SlideJoint(body, other, (10,0), (20,0), 5, 5)
# joint = pm.PinJoint(body, other)
space.add(other, joint)
for i in range(20):
print('step START', i)
space.step(1/60)
print('step END', i)
if i == 10:
print('setting DYNAMIC')
body.body_type = pm.Body.DYNAMIC # Segmentation fault
print('DONE')
print('FINISHED')
Tested on windows and ubuntu. Might be a problem in chipmunk and not pymunk.
Note: I originally found this bug when trying to recalculate the moment for a dynamic body, as I had overwritten it previously and the only easy ways to do it seemed to be to store the original or reset the body type.