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

Daemon threads seem to be broken #35

Open
JustAMan opened this issue Jun 16, 2016 · 0 comments
Open

Daemon threads seem to be broken #35

JustAMan opened this issue Jun 16, 2016 · 0 comments

Comments

@JustAMan
Copy link

I have changed x.py to be the following:

import threading                                          
import sys                                                
import time                                               

def fib(n):                                               
    if n < 2: return 1                                    
    return fib(n-1) + fib(n-2)                            

def test():                                               
    print(fib(30))                                        

threads = 7                                               

if len(sys.argv) > 1:                                     
    threads = int(sys.argv[1])                            

for i in range(threads - 1):                              
    threading.Thread(target=test, daemon=True).start()    

time.sleep(3)                                             

and after a few runs got a segfault.

My current understanding is that when interpreter is shutting down it calls _PyGILState_Fini at some point which invalidates TLS key to PyThreadState, so PyThreadState_GET yields NULL thread state leading to a crash.

I'm not sure how to fix that, and I think it's kind of low priority now, but I though I'll put an issue about that anyway.

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

1 participant