openai / mujoco-py

MuJoCo is a physics engine for detailed, efficient rigid body simulations with contacts. mujoco-py allows using MuJoCo from Python 3.
Other
2.87k stars 814 forks source link

Segmentation fault when imported with other mujoco dependent packages #392

Open hyparxis opened 5 years ago

hyparxis commented 5 years ago

Describe the bug I have an OpenAI Gym library (https://github.com/p-morais/gym-cassie) that uses a custom ctypes wrapper for a C library that uses MuJoCo 1.5. The problem is when I import my library AND the gym mujoco envs, gym.make("Walker2d-v2") etc triggers a segfault. They are using separate versions of Mujoco (1.5 vs 2.0) so that may have something to do with it. I posted the gdb trace below.

To Reproduce I'm not sure what the minimal reproducible code is, but provided you have gym_cassie installed (which is easy with pip install provided you have mjpro150 and mjkey.txt in ~/.mujoco) then the following triggers it:

import gym
import gym_cassie
gym.make("Walker2d-v2")

Expected behavior Should either support both environments being imported, or should fail gracefully without segfaulting.

Error Messages Running in gdb produces:

Program received signal SIGSEGV, Segmentation fault.
0x00007fffd3ce8192 in __pyx_f_9mujoco_py_4cymj_9PyMjModel__extract_mj_names (
    __pyx_v_self=__pyx_v_self@entry=0x555556af0308, 
    __pyx_v_p=__pyx_v_p@entry=0x5555572c3c10, 
    __pyx_v_name_adr=<optimized out>, __pyx_v_n=8, 
    __pyx_v_obj_type=__pyx_v_obj_type@entry=mjOBJ_BODY)
    at /home/beast/p-morais/mjp/mujoco-py/mujoco_py/cymj.c:24106
24106       __pyx_v_name = (__pyx_v_p->names + (__pyx_v_name_adr[__pyx_v_i]));

Desktop (please complete the following information):

Environment

MillionIntegrals commented 5 years ago

Version mismatch in the underlying compiled library can be a cause for a segfault, but it's hard for us to control external factors like that.

Way to go forward is to either upgrade all your dependencies to MuJoCo 2.0 or to stick to an older version of mujoco-py.