Skip to content

Issue with debugpy affecting objects refcount #1854

@Andrej730

Description

@Andrej730

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:

  1. Running it just using python test.py - prints 2 as the refcount and produce no errors.

  2. Running it using VS Code's "Debug Python File"
    Image
    or by uncommenting debugpy part and attaching debugger later - it prints 2 but fails with an error.

  3. Running it with VS Code/debugpy debugger but setting breakpoint at x = np.ones(3) and then stepping through all lines - then it prints 3 and also fails with an error.

Expected behavior

Code execution not to be affected by the debugging process.

Related - IfcOpenShell/IfcOpenShell#6256

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneeds reproIssue has not been reproduced yet

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions