Repository navigation
BUG: Fix a reference count leak in npy_find_descr_for_scalar. - #27666
Conversation
The reference count for common->singleton is incremented twice, when it should only be incremented once. This leak was found when running Google's tests with NumPy 2.1.2, and appears to be a new leak as of NumPy 2.1, probably introduced in numpy@1cb4044. In particular, this test: https://github.com/protocolbuffers/protobuf/blob/6cb71402940c6645e49959dfc915f16f4d2e6c20/python/google/protobuf/internal/numpy/numpy_test.py#L67 runs in Py_DEBUG mode and verifies that the total reference count before and after various test cases is unchanged. The same test case has found other NumPy reference count leaks in the past and it may be sensible to add something similar to NumPy's own test suite.
|
Thanks @hawkinsp. I don't mind adding tests, but basically running full leak checking is becoming more and more cumbersome unless I am sure our test suite covers all of this, but pytest requires magic to reliably run a test multiple times to see if it leaks. So, adding test seems a bit "meh" to me. Making sure that running |
The reference count for common->singleton is incremented twice, when it should only be incremented once.
This leak was found when running Google's tests with NumPy 2.1.2, and appears to be a new leak as of NumPy 2.1, probably introduced in 1cb4044.
In particular, this test:
https://github.com/protocolbuffers/protobuf/blob/6cb71402940c6645e49959dfc915f16f4d2e6c20/python/google/protobuf/internal/numpy/numpy_test.py runs in Py_DEBUG mode and verifies that the total reference count before and after various test cases is unchanged. The same test case has found other NumPy reference count leaks in the past and it may be sensible to add something similar to NumPy's own test suite.
@seberg