BUG: new reference is not decreased due to the `return NULL` statement in macro `import_array` (static analyzer reports)
See original GitHub issueDue to the return NULL
statement in macro import_array
provided by NumPy, the following new references are leaked.
https://github.com/scipy/scipy/blob/d5e46add54425278eb7022e4d49f92e02b96ce8c/scipy/integrate/_odepackmodule.c#L830 https://github.com/scipy/scipy/blob/d5e46add54425278eb7022e4d49f92e02b96ce8c/scipy/integrate/_quadpackmodule.c#L34 https://github.com/scipy/scipy/blob/d5e46add54425278eb7022e4d49f92e02b96ce8c/scipy/interpolate/src/_fitpackmodule.c#L1555 https://github.com/scipy/scipy/blob/d5e46add54425278eb7022e4d49f92e02b96ce8c/scipy/ndimage/src/nd_image.c#L1184 https://github.com/scipy/scipy/blob/d5e46add54425278eb7022e4d49f92e02b96ce8c/scipy/optimize/_lsap_module.c#L121 https://github.com/scipy/scipy/blob/d5e46add54425278eb7022e4d49f92e02b96ce8c/scipy/optimize/_minpackmodule.c#L34 https://github.com/scipy/scipy/blob/d5e46add54425278eb7022e4d49f92e02b96ce8c/scipy/signal/_sigtoolsmodule.c#L1418 https://github.com/scipy/scipy/blob/d5e46add54425278eb7022e4d49f92e02b96ce8c/scipy/signal/_splinemodule.c#L559 https://github.com/scipy/scipy/blob/d5e46add54425278eb7022e4d49f92e02b96ce8c/scipy/sparse/sparsetools/sparsetools.cxx#L570 https://github.com/scipy/scipy/blob/d5e46add54425278eb7022e4d49f92e02b96ce8c/scipy/spatial/src/distance_wrap.c#L855
Internal Report IDs: 0bfe48 77bbba a43576 3eb20e e2207c be4614 24e435 076730 da7180 bb9ac7
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
@rgommers
It is a new experimental checker for Clang Static Analyzer. And it is a part of my research that started in 2019 and has not been published yet.
The reports are from the first time I ran the analyzer on this project. Although these reports were legacy reports a couple of months ago, I have confirmed that such problems still exist in the latest version.
Since I also found similar bugs in NumPy (issue 21532), I definitely know it is difficult and of low priority to fix such bugs. However, as an analyzer vendor and to satisfy my paper reviewers, I have to submit them to prove the effectiveness of my research.
I think the suggestion from @mckib2 seems to be a good idea and worth trying, as there are no data dependencies between
import_array
and the module you are initializing. Maybe we can also use this solution to fix the bugs in NumPy and its programming guidelines if it works for this project.The developers of NumPy also said this. However, module importing can be wrapped with a try block, and a failed importing does not always means program termination (e.g. try an alternative module). Therefore, I think although it is of low priority, it is still worth fixing.
@rgommers Thanks a lot. I will try my best to edit my paper and make it get published asap.