Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Prevent crash during debugging when attempting to inspect PyObject #1483

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

Merged
merged 2 commits into from
Jul 7, 2021

Conversation

lostmsu
Copy link
Member

@lostmsu lostmsu commented Jul 7, 2021

What does this implement/fix? Explain your changes.

When debugging code, that uses PyObject instances, debugger would try to execute PyObject.ToString to show PyObject values in watches window. That call causes AccessViolationException when the current thread does not hold global interpreter lock.

This change adds DebuggerDisplay attribute to PyObject, that makes debugger first check if GIL is held by the current thread, and only use ToString when it does. Otherwise, a message with object handle and a suggestion to acquire GIL is displayed.

@lostmsu lostmsu added the mini label Jul 7, 2021
@lostmsu lostmsu merged commit d300111 into pythonnet:master Jul 7, 2021
@lostmsu lostmsu deleted the Mini/DebugViewNoCrash branch July 7, 2021 18:12
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

Successfully merging this pull request may close these issues.

2 participants