Bug Summary

File:_devicearray.cpp
Warning:line 136, column 5
Calling function '_Py_XDECREF' with a PyObject argument whose ownership has been released

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 _devicearray.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/numba/csa-scan,ctu-index-name=/tmp/pyrefcon/numba/csa-scan/externalDefMap.txt,ctu-invocation-list=/tmp/pyrefcon/numba/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 -fmath-errno -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/numba -resource-dir /opt/pyrefcon/lib/clang/13.0.0 -isystem /opt/pyrefcon/lib/pyrefcon/models/python3.8 -D NDEBUG -D _FORTIFY_SOURCE=2 -I numba -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 -std=c++11 -fdeprecated-macro -fdebug-compilation-dir=/tmp/pyrefcon/numba -ferror-limit 19 -fwrapv -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/numba/csa-scan/reports -x c++ numba/_devicearray.cpp

numba/_devicearray.cpp

1/* This file contains the base class implementation for all device arrays. The
2 * base class is implemented in C so that computing typecodes for device arrays
3 * can be implemented efficiently. */
4
5#include "_pymodule.h"
6
7
8/* Include _devicearray., but make sure we don't get the definitions intended
9 * for consumers of the Device Array API.
10 */
11#define NUMBA_IN_DEVICEARRAY_CPP_
12#include "_devicearray.h"
13
14/* DeviceArray PyObject implementation. Note that adding more members here is
15 * presently prohibited because mapped and managed arrays derive from both
16 * DeviceArray and NumPy's ndarray, which is also a C extension class - the
17 * layout of the object cannot be resolved if this class also has members beyond
18 * PyObject_HEAD. */
19class DeviceArray {
20 PyObject_HEADPyObject ob_base;
21};
22
23/* Trivial traversal - DeviceArray instances own nothing. */
24static int
25DeviceArray_traverse(DeviceArray *self, visitproc visit, void *arg)
26{
27 return 0;
28}
29
30/* Trivial clear of all references - DeviceArray instances own nothing. */
31static int
32DeviceArray_clear(DeviceArray *self)
33{
34 return 0;
35}
36
37/* The _devicearray.DeviceArray type */
38PyTypeObject DeviceArrayType = {
39 PyVarObject_HEAD_INIT(NULL, 0){ { 1, __null }, 0 },
40 "_devicearray.DeviceArray", /* tp_name */
41 sizeof(DeviceArray), /* tp_basicsize */
42 0, /* tp_itemsize */
43 0, /* tp_dealloc */
44 0, /* tp_print */
45 0, /* tp_getattr */
46 0, /* tp_setattr */
47 0, /* tp_compare */
48 0, /* tp_repr */
49 0, /* tp_as_number */
50 0, /* tp_as_sequence */
51 0, /* tp_as_mapping */
52 0, /* tp_hash */
53 0, /* tp_call*/
54 0, /* tp_str*/
55 0, /* tp_getattro*/
56 0, /* tp_setattro*/
57 0, /* tp_as_buffer*/
58 Py_TPFLAGS_DEFAULT( 0 | (1UL << 18) | 0) | Py_TPFLAGS_BASETYPE(1UL << 10) | Py_TPFLAGS_HAVE_GC(1UL << 14),
59 /* tp_flags*/
60 "DeviceArray object", /* tp_doc */
61 (traverseproc) DeviceArray_traverse, /* tp_traverse */
62 (inquiry) DeviceArray_clear, /* tp_clear */
63 0, /* tp_richcompare */
64 0, /* tp_weaklistoffset */
65 0, /* tp_iter */
66 0, /* tp_iternext */
67 0, /* tp_methods */
68 0, /* tp_members */
69 0, /* tp_getset */
70 0, /* tp_base */
71 0, /* tp_dict */
72 0, /* tp_descr_get */
73 0, /* tp_descr_set */
74 0, /* tp_dictoffset */
75 0, /* tp_init */
76 0, /* tp_alloc */
77 0, /* tp_new */
78 0, /* tp_free */
79 0, /* tp_is_gc */
80 0, /* tp_bases */
81 0, /* tp_mro */
82 0, /* tp_cache */
83 0, /* tp_subclasses */
84 0, /* tp_weaklist */
85 0, /* tp_del */
86 0, /* tp_version_tag */
87 0, /* tp_finalize */
88#if PY_MAJOR_VERSION3 == 3 && PY_MINOR_VERSION8 == 8
89 0, /* tp_vectorcall */
90 0, /* tp_print */
91#endif
92};
93
94/* CUDA device array C API */
95static void *_DeviceArray_API[1] = {
96 (void*)&DeviceArrayType
97};
98
99MOD_INIT(_devicearray)extern "C" PyObject* PyInit__devicearray(void) {
100 PyObject *m = nullptr;
101 PyObject *d = nullptr;
102 PyObject *c_api = nullptr;
103 int error = 0;
104
105 MOD_DEF(m, "_devicearray", "No docs", NULL){ static struct PyModuleDef moduledef = { { { 1, __null }, __null
, 0, __null, }, "_devicearray", "No docs", -1, __null, __null
, __null, __null, __null }; m = PyModule_Create2(&moduledef
, 1013); }
106 if (m == NULL__null)
1
Assuming 'm' is not equal to NULL
2
Taking false branch
107 goto error_occurred;
108
109 c_api = PyCapsule_New((void *)_DeviceArray_API, "numba._devicearray._DEVICEARRAY_API", NULL__null);
3
Calling 'PyCapsule_New'
5
Returning from 'PyCapsule_New'
110 if (c_api == NULL__null)
6
Assuming 'c_api' is not equal to NULL
7
Taking false branch
111 goto error_occurred;
112
113 DeviceArrayType.tp_new = PyType_GenericNew;
114 if (PyType_Ready(&DeviceArrayType) < 0)
8
Assuming the condition is false
9
Taking false branch
115 goto error_occurred;
116
117 Py_INCREF(&DeviceArrayType)_Py_INCREF(((PyObject*)(&DeviceArrayType)));
118 error = PyModule_AddObject(m, "DeviceArray", (PyObject*)(&DeviceArrayType));
119 if (error)
10
Assuming 'error' is 0
11
Taking false branch
120 goto error_occurred;
121
122 d = PyModule_GetDict(m);
123 if (d == NULL__null)
12
Assuming 'd' is not equal to NULL
13
Taking false branch
124 goto error_occurred;
125
126 error = PyDict_SetItemString(d, "_DEVICEARRAY_API", c_api);
127 Py_DECREF(c_api)_Py_DECREF(((PyObject*)(c_api)));
14
Calling '_Py_DECREF'
16
Returning from '_Py_DECREF'
128
129 if (error)
17
Assuming 'error' is not equal to 0
18
Taking true branch
130 goto error_occurred;
19
Control jumps to line 135
131
132 return MOD_SUCCESS_VAL(m)m;
133
134error_occurred:
135 Py_XDECREF(m)_Py_XDECREF(((PyObject*)(m)));
136 Py_XDECREF(c_api)_Py_XDECREF(((PyObject*)(c_api)));
20
Calling function '_Py_XDECREF' with a PyObject argument whose ownership has been released
137 Py_XDECREF((PyObject*)&DeviceArrayType)_Py_XDECREF(((PyObject*)((PyObject*)&DeviceArrayType)));
138
139 return MOD_ERROR_VAL__null;
140}

/opt/pyrefcon/lib/pyrefcon/models/models/PyCapsule_New.model

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

/opt/pyrefcon/lib/pyrefcon/models/models/_Py_DECREF.model

1void _Py_DECREF(PyObject *op) { --op->ob_refcnt; }
15
Setting reference count to 0