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

Segfault related to attach by reference #2482

Open
2 tasks done
jjyyxx opened this issue Mar 7, 2025 · 0 comments
Open
2 tasks done

Segfault related to attach by reference #2482

jjyyxx opened this issue Mar 7, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@jjyyxx
Copy link
Contributor

jjyyxx commented Mar 7, 2025

Intro

Hi!

I am a graduate student at HKU, I use MuJoCo for my research on robotic manipulation.

My setup

MuJoCo 3.3.0, Python and C, Linux

What's happening? What did you expect?

See snippets below. Both snippets show segfault.

Also, when spec2 is compiled and to_xml before detaching, the result contains two levels of default, making MJCF invalid.

Steps for reproduction

Run snippet below.

Minimal model for reproduction

No response

Code required for reproduction

Case 1 (somehow cannot garbage collect *2?):

import mujoco
spec1 = mujoco.MjSpec.from_string("""
<mujoco>
<worldbody>
    <body name="a"/>
</worldbody>
</mujoco>
""")
spec2 = mujoco.MjSpec()
body1 = spec1.body('a')
frame2 = spec2.worldbody.add_frame()
body2 = frame2.attach_body(body1)
spec2.compile()
del frame2
del body2
del spec2
spec1.compile()

Case 2 (cannot detach after attaching then detaching from another spec)

import mujoco
spec1 = mujoco.MjSpec.from_string("""
<mujoco>
<worldbody>
    <body name="a"/>
</worldbody>
</mujoco>
""")
spec2 = mujoco.MjSpec()
body1 = spec1.body('a')
frame2 = spec2.worldbody.add_frame()
body2 = frame2.attach_body(body1)
spec2.detach_body(body2)
spec2.compile()
spec1.detach_body(body1)
spec1.compile()

Confirmations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants