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

Segfaulting Unrelated Threads? #341

Open
mharradon opened this issue Apr 13, 2020 · 2 comments
Open

Segfaulting Unrelated Threads? #341

mharradon opened this issue Apr 13, 2020 · 2 comments

Comments

@mharradon
Copy link

mharradon commented Apr 13, 2020

I've found what I believe to be quite the mysterious (and painful) bug.

A minimal reproducing example:

from threading import Thread
import faulthandler

import gym

faulthandler.enable()

def make_t2():
    print(1)

def make_t1():
    t = Thread(target=make_t2)
    t.start()

env = gym.make('MsPacman-v4')
#env = gym.make('CartPole-v0')

t = Thread(target=make_t1)
t.start()

I believe it's related to this issue: openai/atari-py#52

Essentially, it appears that nesting of threads segfault if and only if gym.make has occurred. If you comment out that line the error goes away.

This issue appeared sometime since gym release 0.15.3 . The older versions don't seem to have this problem.

If I use faulthandler I can get:

 $ python error_demo.py
1
Fatal Python error: Segmentation fault

Thread 0x00007f6b01327700 (most recent call first):
  File "/root/anaconda3/lib/python3.7/threading.py", line 989 in _stop
  File "/root/anaconda3/lib/python3.7/threading.py", line 1282 in _shutdown
[1]    83051 segmentation fault (core dumped)  python error_demo.py

So, at least as I understand, it is not even gym code that is segfaulting - rather it is somehow indirectly causing other code to segfault. I was suggested to post here from the gym repo, as this only occurs with Atari environments.

I'm using Python3.7.

Thanks!

@JesseFarebro
Copy link
Collaborator

Hi,

Can you give me more details about your setup? I ran your example using Python 3.7.1 on macOS and it doesn't segfault. Neither does the other issue you linked above.

@mharradon
Copy link
Author

The issue occurs on 3.7.3 in a Docker container. I'll try to provide a container that reproduces it. I see it doesn't occur on my Mac with 3.7.3, though both are Anaconda distributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants