-
Notifications
You must be signed in to change notification settings - Fork 147
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
Crashes on ending debug session when using PyPy #1198
Comments
Closing old issue. If this is still a problem, please reopen with the information requested. thanks |
This is still an issue (not sure if it's at pypy end or debugpy) |
Requesting for this issue to be reopened
Program crashes on ending debug session with the following error
Expected behavior: No crashes Steps to reproduce:
L2=[10,20,30, 40, 50]
L2.reverse()
print(L2)
|
This seems like a bug in PyPy to me. Debugpy is calling |
Does the crash always happen? It seems very strange. The code, which is taken directly from CPython calls
But I also see that debugpy is switching out a lock, maybe that is somehow messing things up? |
Note the original thread lock code uses |
change |
Cool. @judej, @rchiodo could debugpy change the lock? I would submit the change but it requires a CLA and all that, which is too many hoops for a one line change. diff --git a/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_script.py b/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_script.py
index eb5f8d0a..78d397f5 100644
--- a/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_script.py
+++ b/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_script.py
@@ -109,7 +109,7 @@ def fix_main_thread_id(on_warn=lambda msg: None, on_exception=lambda msg: None,
# to the thread state and will be released when the secondary thread
# that initialized the lock is finished -- making an assert fail during
# process shutdown.
- main_thread_instance._tstate_lock = threading._allocate_lock()
+ main_thread_instance._tstate_lock = threading._set_sentinel()
main_thread_instance._tstate_lock.acquire()
# Actually patch the thread ident as well as the threading._active dict
I wonder if there is a way to write a test for this, especially since it only seems to affect PyPy |
I can try a submission. Our tests should validate this code path. Not sure what the difference is between |
Thanks |
I still think PyPy needs to change here. Updated to match CPython? Or maybe there's another change that uses public apis instead of the private Oh actually |
The difference between |
What I'm still not sure of is why we don't see this same crash with CPython. Say CPython 3.11 that looks like the threading code is identical. |
It's also unclear how the mentioned code is actually run. That code should only run on attach AFAIK, @TechPro424 are you doing an attach? |
No |
That changed for the still-unreleased python 3.13, in response to (mainly) an issue in free-threading python/cpython#116372. For earlier versions we are stuck with the "private" thread internals debugpy is overriding in a non-compatible way. |
I tried this myself. That code is not run when doing a launch. Not sure how it worked for @TechPro424. Changing that line has no effect on it crashing for me. Internally it looks like debugpy doesn't necessarily work with other python runtimes. The work we do around tracing specific threads only works in CPython. I would guess this is much more complicated than a single line change. |
The source of the problem is not on your side. If you replace The actual issue was fixed in the |
Before creating a new issue, please check the FAQ to see if your question is answered there.
Environment data
Actual behavior
Program crashes on ending debug session with the following error
Expected behavior
No crashes
Steps to reproduce:
The text was updated successfully, but these errors were encountered: