-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Description
Describe the bug
When a function has multiple memory view arguments, and the argument call fails because of a type-mismatch then it can leak references to original array being viewed.
To Reproduce
In memleak.pyx:
def foo(double[:] a, double[:] b):
passand in repro.py:
import sys
import numpy as np
from memleak import foo
a = np.random.rand(100)
b = np.random.randint(100)
for i in range(1000):
try:
foo(a, b)
except:
pass
if i % 100 == 0:
print(sys.getrefcount(a), sys.getrefcount(b))foo is called with a valid array for a but an invalid b. The result is a's refcount is constantly increasing:
4 12
204 12
404 12
604 12
804 12
1004 12
1204 12
1404 12
1604 12
1804 12
Expected behavior
The refcount of a should be constant, like it is for b.
Environment (please complete the following information):
- OS: Linux
- Python version 3.8.8
- Cython version 0.29.23
Reactions are currently unavailable