Bug Summary

File:/tmp/pyrefcon/scipy/scipy/signal/_max_len_seq_inner.cpp
Warning:line 232, column 25
PyObject ownership leak with reference count of 1

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name _max_len_seq_inner.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -analyzer-output=html -analyzer-checker=python -analyzer-disable-checker=deadcode -analyzer-config prune-paths=true,suppress-c++-stdlib=true,suppress-null-return-paths=false,crosscheck-with-z3=true,model-path=/opt/pyrefcon/lib/pyrefcon/models/models -analyzer-config experimental-enable-naive-ctu-analysis=true,ctu-dir=/tmp/pyrefcon/scipy/csa-scan,ctu-index-name=/tmp/pyrefcon/scipy/csa-scan/externalDefMap.txt,ctu-invocation-list=/tmp/pyrefcon/scipy/csa-scan/invocations.yaml,display-ctu-progress=false -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -fcoverage-compilation-dir=/tmp/pyrefcon/scipy -resource-dir /opt/pyrefcon/lib/clang/13.0.0 -isystem /opt/pyrefcon/lib/pyrefcon/models/python3.8 -D NDEBUG -D _FORTIFY_SOURCE=2 -D ENABLE_PYTHON_MODULE -D __PYTHRAN__=3 -D PYTHRAN_BLAS_NONE -I /home/pyrefcon/.local/lib/python3.8/site-packages/pythran -I /usr/lib/python3/dist-packages/numpy/core/include -I /usr/lib/python3/dist-packages/numpy/core/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /opt/pyrefcon/lib/clang/13.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-result -Wsign-compare -Wall -Wformat -Werror=format-security -Wformat -Werror=format-security -Wdate-time -Wno-unused-function -Wno-int-in-bool-context -Wno-unknown-warning-option -std=c++11 -fdeprecated-macro -fdebug-compilation-dir=/tmp/pyrefcon/scipy -ferror-limit 19 -fvisibility hidden -pthread -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/pyrefcon/scipy/csa-scan/reports -x c++ scipy/signal/_max_len_seq_inner.cpp

scipy/signal/_max_len_seq_inner.cpp

1#include <pythonic/core.hpp>
2#include <pythonic/python/core.hpp>
3#include <pythonic/types/bool.hpp>
4#include <pythonic/types/int.hpp>
5#ifdef _OPENMP
6#include <omp.h>
7#endif
8#include <pythonic/include/types/int8.hpp>
9#include <pythonic/include/types/ndarray.hpp>
10#include <pythonic/include/types/int64.hpp>
11#include <pythonic/include/types/int.hpp>
12#include <pythonic/types/ndarray.hpp>
13#include <pythonic/types/int.hpp>
14#include <pythonic/types/int64.hpp>
15#include <pythonic/types/int8.hpp>
16#include <pythonic/include/builtins/getattr.hpp>
17#include <pythonic/include/builtins/range.hpp>
18#include <pythonic/include/numpy/roll.hpp>
19#include <pythonic/include/operator_/add.hpp>
20#include <pythonic/include/operator_/ixor.hpp>
21#include <pythonic/include/operator_/mod.hpp>
22#include <pythonic/include/operator_/neg.hpp>
23#include <pythonic/include/operator_/xor_.hpp>
24#include <pythonic/include/types/str.hpp>
25#include <pythonic/builtins/getattr.hpp>
26#include <pythonic/builtins/range.hpp>
27#include <pythonic/numpy/roll.hpp>
28#include <pythonic/operator_/add.hpp>
29#include <pythonic/operator_/ixor.hpp>
30#include <pythonic/operator_/mod.hpp>
31#include <pythonic/operator_/neg.hpp>
32#include <pythonic/operator_/xor_.hpp>
33#include <pythonic/types/str.hpp>
34namespace __pythran__max_len_seq_inner
35{
36 struct _max_len_seq_inner
37 {
38 typedef void callable;
39 ;
40 template <typename argument_type0 , typename argument_type1 , typename argument_type2 , typename argument_type3 , typename argument_type4 >
41 struct type
42 {
43 typedef typename std::remove_cv<typename std::remove_reference<argument_type1>::type>::type __type0;
44 typedef typename pythonic::assignable<long>::type __type1;
45 typedef decltype(std::declval<__type0>()[std::declval<__type1>()]) __type2;
46 typedef typename pythonic::assignable<decltype(std::declval<__type0>()[std::declval<__type1>()])>::type __type3;
47 typedef container<typename std::remove_reference<__type2>::type> __type5;
48 typedef typename __combined<__type0,__type5>::type __type6;
49 typedef typename std::remove_cv<typename std::remove_reference<argument_type0>::type>::type __type7;
50 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::builtins::functor::range{})>::type>::type __type8;
51 typedef decltype(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, std::declval<__type7>())) __type10;
52 typedef typename std::tuple_element<0,typename std::remove_reference<__type10>::type>::type __type11;
53 typedef typename pythonic::lazy<__type11>::type __type12;
54 typedef decltype(std::declval<__type8>()(std::declval<__type12>())) __type13;
55 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type13>::type::iterator>::value_type>::type __type14;
56 typedef decltype(std::declval<__type7>()[std::declval<__type14>()]) __type15;
57 typedef decltype(pythonic::operator_::add(std::declval<__type15>(), std::declval<__type1>())) __type17;
58 typedef typename std::remove_cv<typename std::remove_reference<argument_type2>::type>::type __type18;
59 typedef decltype(pythonic::operator_::mod(std::declval<__type17>(), std::declval<__type18>())) __type19;
60 typedef decltype(std::declval<__type6>()[std::declval<__type19>()]) __type20;
61 typedef typename __combined<__type3,__type20>::type __type21;
62 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::numpy::functor::roll{})>::type>::type __type22;
63 typedef container<typename std::remove_reference<__type20>::type> __type23;
64 typedef container<typename std::remove_reference<__type21>::type> __type25;
65 typedef indexable<__type1> __type27;
66 typedef typename __combined<__type0,__type5,__type23,__type25,__type27>::type __type28;
67 typedef long __type31;
68 typedef decltype(pythonic::operator_::add(std::declval<__type1>(), std::declval<__type31>())) __type32;
69 typedef typename pythonic::assignable<decltype(pythonic::operator_::mod(std::declval<__type32>(), std::declval<__type18>()))>::type __type34;
70 typedef typename __combined<__type1,__type34>::type __type35;
71 typedef decltype(pythonic::operator_::neg(std::declval<__type35>())) __type36;
72 typedef __type2 __ptype0;
73 typedef __type21 __ptype1;
74 typedef typename pythonic::returnable<decltype(std::declval<__type22>()(std::declval<__type28>(), std::declval<__type36>(), std::declval<__type31>()))>::type result_type;
75 }
76 ;
77 template <typename argument_type0 , typename argument_type1 , typename argument_type2 , typename argument_type3 , typename argument_type4 >
78 typename type<argument_type0, argument_type1, argument_type2, argument_type3, argument_type4>::result_type operator()(argument_type0&& taps, argument_type1&& state, argument_type2&& nbits, argument_type3&& length, argument_type4&& seq) const
79 ;
80 } ;
81 template <typename argument_type0 , typename argument_type1 , typename argument_type2 , typename argument_type3 , typename argument_type4 >
82 typename _max_len_seq_inner::type<argument_type0, argument_type1, argument_type2, argument_type3, argument_type4>::result_type _max_len_seq_inner::operator()(argument_type0&& taps, argument_type1&& state, argument_type2&& nbits, argument_type3&& length, argument_type4&& seq) const
83 {
84 typedef typename pythonic::assignable<long>::type __type0;
85 typedef long __type2;
86 typedef decltype(pythonic::operator_::add(std::declval<__type0>(), std::declval<__type2>())) __type3;
87 typedef typename std::remove_cv<typename std::remove_reference<argument_type2>::type>::type __type4;
88 typedef typename pythonic::assignable<decltype(pythonic::operator_::mod(std::declval<__type3>(), std::declval<__type4>()))>::type __type5;
89 typedef typename std::remove_cv<typename std::remove_reference<argument_type1>::type>::type __type6;
90 typedef typename __combined<__type0,__type5>::type __type8;
91 typedef decltype(std::declval<__type6>()[std::declval<__type8>()]) __type9;
92 typedef container<typename std::remove_reference<__type9>::type> __type10;
93 typedef typename __combined<__type6,__type10>::type __type11;
94 typedef typename std::remove_cv<typename std::remove_reference<argument_type0>::type>::type __type12;
95 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::builtins::functor::range{})>::type>::type __type13;
96 typedef decltype(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, std::declval<__type12>())) __type15;
97 typedef typename std::tuple_element<0,typename std::remove_reference<__type15>::type>::type __type16;
98 typedef typename pythonic::lazy<__type16>::type __type17;
99 typedef decltype(std::declval<__type13>()(std::declval<__type17>())) __type18;
100 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type18>::type::iterator>::value_type>::type __type19;
101 typedef decltype(std::declval<__type12>()[std::declval<__type19>()]) __type20;
102 typedef decltype(pythonic::operator_::add(std::declval<__type20>(), std::declval<__type8>())) __type22;
103 typedef decltype(pythonic::operator_::mod(std::declval<__type22>(), std::declval<__type4>())) __type24;
104 typedef decltype(std::declval<__type11>()[std::declval<__type24>()]) __type25;
105 typedef container<typename std::remove_reference<__type25>::type> __type26;
106 typedef typename pythonic::assignable<decltype(std::declval<__type6>()[std::declval<__type8>()])>::type __type27;
107 typedef typename __combined<__type27,__type25>::type __type28;
108 typedef container<typename std::remove_reference<__type28>::type> __type29;
109 typedef indexable<__type8> __type31;
110 typename pythonic::lazy<decltype(std::get<0>(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, taps)))>::type n_taps = std::get<0>(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, taps));
111 typename pythonic::assignable<typename __combined<__type0,__type5>::type>::type idx = 0L;
112 {
113 long __target139669609775744 = length;
114 for (long i=0L; i < __target139669609775744; i += 1L)
115 {
116 typename pythonic::assignable<typename __combined<__type27,__type25>::type>::type feedback = state.fast(idx);
117 seq.fast(i) = feedback;
118 {
119 long __target139669609777520 = n_taps;
120 for (long ti=0L; ti < __target139669609777520; ti += 1L)
121 {
122 feedback ^= state.fast(pythonic::operator_::mod(pythonic::operator_::add(taps.fast(ti), idx), nbits));
123 }
124 }
125 state.fast(idx) = feedback;
126 idx = pythonic::operator_::mod(pythonic::operator_::add(idx, 1L), nbits);
127 }
128 }
129 return pythonic::numpy::functor::roll{}(state, pythonic::operator_::neg(idx), 0L);
130 }
131}
132#include <pythonic/python/exception_handler.hpp>
133#ifdef ENABLE_PYTHON_MODULE1
134typename __pythran__max_len_seq_inner::_max_len_seq_inner::type<pythonic::types::ndarray<npy_int64,pythonic::types::pshape<long>>, pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>, long, long, pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>>::result_type _max_len_seq_inner0(pythonic::types::ndarray<npy_int64,pythonic::types::pshape<long>>&& taps, pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>&& state, long&& nbits, long&& length, pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>&& seq)
135{
136
137 PyThreadState *_save = PyEval_SaveThread();
138 try {
139 auto res = __pythran__max_len_seq_inner::_max_len_seq_inner()(taps, state, nbits, length, seq);
140 PyEval_RestoreThread(_save);
141 return res;
142 }
143 catch(...) {
144 PyEval_RestoreThread(_save);
145 throw;
146 }
147 ;
148}
149
150static PyObject *
151__pythran_wrap__max_len_seq_inner0(PyObject *self, PyObject *args, PyObject *kw)
152{
153 PyObject* args_obj[5+1];
154
155 char const* keywords[] = {"taps", "state", "nbits", "length", "seq", nullptr};
156 if(! PyArg_ParseTupleAndKeywords(args, kw, "OOOOO",
157 (char**)keywords , &args_obj[0], &args_obj[1], &args_obj[2], &args_obj[3], &args_obj[4]))
158 return nullptr;
159 if(is_convertible<pythonic::types::ndarray<npy_int64,pythonic::types::pshape<long>>>(args_obj[0]) && is_convertible<pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>>(args_obj[1]) && is_convertible<long>(args_obj[2]) && is_convertible<long>(args_obj[3]) && is_convertible<pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>>(args_obj[4]))
160 return to_python(_max_len_seq_inner0(from_python<pythonic::types::ndarray<npy_int64,pythonic::types::pshape<long>>>(args_obj[0]), from_python<pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>>(args_obj[1]), from_python<long>(args_obj[2]), from_python<long>(args_obj[3]), from_python<pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>>(args_obj[4])));
161 else {
162 return nullptr;
163 }
164}
165
166 static PyObject *
167 __pythran_wrapall__max_len_seq_inner(PyObject *self, PyObject *args, PyObject *kw)
168 {
169 return pythonic::handle_python_exception([self, args, kw]()
170 -> PyObject* {
171
172if(PyObject* obj = __pythran_wrap__max_len_seq_inner0(self, args, kw))
173 return obj;
174PyErr_Clear();
175
176 return pythonic::python::raise_invalid_argument(
177 "_max_len_seq_inner", "\n"" - _max_len_seq_inner(int64[:], int8[:], int, int, int8[:])", args, kw);
178 });
179 }
180
181
182static PyMethodDef Methods[] = {
183 {
184 "_max_len_seq_inner",
185 (PyCFunction)__pythran_wrapall__max_len_seq_inner,
186 METH_VARARGS0x0001 | METH_KEYWORDS0x0002,
187 "Supported prototypes:\n""\n"" - _max_len_seq_inner(int64[:], int8[:], int, int, int8[:])"},
188 {NULL__null, NULL__null, 0, NULL__null}
189};
190
191
192#if PY_MAJOR_VERSION3 >= 3
193 static struct PyModuleDef moduledef = {
194 PyModuleDef_HEAD_INIT{ { 1, __null }, __null, 0, __null, },
195 "_max_len_seq_inner", /* m_name */
196 "", /* m_doc */
197 -1, /* m_size */
198 Methods, /* m_methods */
199 NULL__null, /* m_reload */
200 NULL__null, /* m_traverse */
201 NULL__null, /* m_clear */
202 NULL__null, /* m_free */
203 };
204#define PYTHRAN_RETURNreturn theModule return theModule
205#define PYTHRAN_MODULE_INIT(s)PyInit_s PyInit_##s
206#else
207#define PYTHRAN_RETURNreturn theModule return
208#define PYTHRAN_MODULE_INIT(s)PyInit_s init##s
209#endif
210PyMODINIT_FUNCextern "C" PyObject*
211PYTHRAN_MODULE_INIT(_max_len_seq_inner)PyInit__max_len_seq_inner(void)
212#ifndef _WIN32
213__attribute__ ((visibility("default")))
214#if defined(GNUC) && !defined(__clang__1)
215__attribute__ ((externally_visible))
216#endif
217#endif
218;
219PyMODINIT_FUNCextern "C" PyObject*
220PYTHRAN_MODULE_INIT(_max_len_seq_inner)PyInit__max_len_seq_inner(void) {
221 import_array(){if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(
PyExc_ImportError, "numpy.core.multiarray failed to import");
return __null; } }
1
Taking false branch
222 #if PY_MAJOR_VERSION3 >= 3
223 PyObject* theModule = PyModule_Create(&moduledef)PyModule_Create2(&moduledef, 1013);
224 #else
225 PyObject* theModule = Py_InitModule3("_max_len_seq_inner",
226 Methods,
227 ""
228 );
229 #endif
230 if(! theModule)
2
Assuming 'theModule' is non-null
3
Taking false branch
231 PYTHRAN_RETURNreturn theModule;
232 PyObject * theDoc = Py_BuildValue("(sss)",
4
Calling 'Py_BuildValue'
6
Returning from 'Py_BuildValue'
9
PyObject ownership leak with reference count of 1
233 "0.9.12",
234 "2021-07-14 11:02:32.655231",
235 "ccd4c6b01dd37c8a698a8beaea85985732ea19d0ab7d0883d689f577fbda0424");
236 if(! theDoc)
7
Assuming 'theDoc' is non-null
8
Taking false branch
237 PYTHRAN_RETURNreturn theModule;
238 PyModule_AddObject(theModule,
239 "__pythran__",
240 theDoc);
241
242
243 PYTHRAN_RETURNreturn theModule;
244}
245
246#endif

/opt/pyrefcon/lib/pyrefcon/models/models/Py_BuildValue.model

1#ifndef Py_BuildValue
2struct _object;
3typedef struct _object PyObject;
4PyObject* clang_analyzer_PyObject_New_Reference();
5PyObject* Py_BuildValue(const char *format, ...) {
6 return clang_analyzer_PyObject_New_Reference();
5
Setting reference count to 1
7}
8#else
9#warning "API Py_BuildValue is defined as a macro."
10#endif