Issue with debugpy affecting objects refcount
@rchiodo is already working on this.
Since Mar 4, 2025.
Assessment
This issue has not been assessed yet.
Description
Environment data
- debugpy version: 1.8.1
- OS and version: Windows 11
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.11
- Using VS Code or Visual Studio: VS Code 1.93.1
Actual behavior
Consider snippet below - when executing with a debugger attached it fails with an error below.
x.resize(4)
ValueError: cannot resize an array that references or is referenced
by another array in this way.
Use the np.resize function or refcheck=False
import numpy as np
import sys
# import debugpy
# debugpy.listen(5678)
# debugpy.wait_for_client()
x = np.ones(3)
print(sys.getrefcount(x))
# ValueError: cannot resize an array that references or is referenced
# by another array in this way.
# Use the np.resize function or refcheck=False
x.resize(4)
print(x)
Investigating I've noticed 3 different behaviours:
-
Running it just using
python test.py- prints2as the refcount and produce no errors. -
Running it using VS Code's "Debug Python File"
or by uncommentingdebugpypart and attaching debugger later - it prints2but fails with an error. -
Running it with VS Code/debugpy debugger but setting breakpoint at
x = np.ones(3)and then stepping through all lines - then it prints3and also fails with an error.
Expected behavior
Code execution not to be affected by the debugging process.
Related - https://github.com/IfcOpenShell/IfcOpenShell/issues/6256
- Dominant language
- Python
- Stars
- 2.5k
- Forks
- 202
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/debugpy
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
All issues in microsoft/debugpy
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
canonical/paas-charm#368 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
StevenBlack/hosts#3256 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
qualcomm/qai-appbuilder#275 ·