-
Notifications
You must be signed in to change notification settings - Fork 8
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
thread.kill() gets stuck endlessly #4
Comments
Can you provide an isolated test case for this? I cannot begin debugging without it as the behavior is inconsistent, and I cannot be sure that it's not due to something specific to your application. It's a potentially endless time-sink. You can try wrapping your calls to go-pthreads functions with runtime.LockOsThread() and runtime.UnlockOsThread(). This will ensure that the calls to pthreads occur in the main OS thread. I'm unsure if this will have any impact. |
Hi, This is an example program I wrote to demonstrate that threads don't exit properly, and sometimes do. https://gist.github.com/kryptodev/b2479035cc09f0d90a6a16b8709b7abb Thank you |
I stripped out all the Python stuff to make sure that the problem actually exists in this library and isn't some python.h logic that dislikes multithreading. It looks like the deadlock appears in pthread.Create(). I'm also creating and destroying the threads serially, so there couldn't be any overlap (eg, killing the wrong thread). Sometimes, the thread doesn't start. C.pthread_create returns status 0 (no error), but it just never runs. If I remove the call to thread.Kill(), my attached script works correctly.[1] However, it appears to be happening if thread.Kill() is called before the thread actually exists. A secondary channel can be used to prevent this by sending a value down this channel before any call to thread.Kill()[2] I've got no idea why this is happening. I don't know the internal details of how pthread operates, and I don't have time to dig too deep in this at the moment. [1] https://gist.github.com/liamzdenek/864b327bc660f4ab445f3729238f038b |
Hello,
I hope I am not simply making a mistake but I have noticed that when I create a pthread inside a new goroutine(not the main), and I try to call thread.kill(), it does not always work. Sometimes I does, other times it just gets stuck.
It would be very kind of you to investigate this in your free time.
Thank you
The text was updated successfully, but these errors were encountered: