-
Notifications
You must be signed in to change notification settings - Fork 47
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
Reduce gdb deadlocks #105
Comments
To clarify, this is a different deadlock than the one pydevd deals with as pydevd code uses |
Well technically it could deadlock - if you manage to attach hunter via gdb at the exact time where a signal would be delivered to the process (signal delivery would use the Py_AddPendingCall routines). It's still better than using PyRun_SimpleString directly tho (that can deadlock way more easier - basically if you run it while something holds the GIL you're in for very unpredictable behavior - including deadlocks). That's why I used Py_AddPendingCall - it's the correct way with regard to the GIL. I disagree with your assessment that VSCode reliably injects code into Python processes, or any debugger that relies on PyRun_SimpleString directly.
Make a PR with the change and lets see how it works. |
Regarding |
How would the GIL get released for a single thread process if you pause said process while the GIL is held somewhere? |
As far as I understand, |
To be honest I don't know the cpython internals well enough to say it's right or wrong. From what I've tried the Py_AddPendingCall worked really well while PyRun_SimpleString didn't. Maybe all I missed was the |
Cool, I'll give the tests a look. I've been meaning to play around with python-hunter in depth for a long time. I hope to have the justification to do so at my day job soon :) |
When using python-hunter's remote feature, a warning is printed that the process may deadlock. (See here.)
I strongly suspect this can be fixed by setting the gdb flag
scheduler-locking off
. IDEs like VSCode reliably inject code into Python processes to support debugging existing processes. VSCode's implementation explicitly mentions the importance of settingscheduler-locking off
to prevent deadlocksI unfortunately don't have the time to open a PR for python-hunter at the moment, but I do plan to maintain a fork of pyrasite with this and other fixes. I will update here if I find additional bugs that can cause deadlocks.
The text was updated successfully, but these errors were encountered: