Bug Summary

File:cuda/cudadrv/_extras.c
Warning:line 42, column 54
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 _extras.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -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 /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 -fdebug-compilation-dir=/tmp/pyrefcon/numba -ferror-limit 19 -fwrapv -pthread -stack-protector 2 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/pyrefcon/numba/csa-scan/reports -x c numba/cuda/cudadrv/_extras.c

numba/cuda/cudadrv/_extras.c

1/*
2 * Helper binding to call some CUDA Runtime API that cannot be directly
3 * encoded using ctypes.
4 */
5
6#include "_pymodule.h"
7
8
9#define CUDA_IPC_HANDLE_SIZE64 64
10
11typedef int CUresult;
12typedef void* CUdeviceptr;
13
14typedef struct CUipcMemHandle_st{
15 char reserved[CUDA_IPC_HANDLE_SIZE64];
16} CUipcMemHandle;
17
18typedef CUresult (*cuIpcOpenMemHandle_t)(CUdeviceptr* pdptr, CUipcMemHandle handle, unsigned int flags );
19
20static
21cuIpcOpenMemHandle_t cuIpcOpenMemHandle = 0;
22
23static
24void set_cuIpcOpenMemHandle(void* fnptr)
25{
26 cuIpcOpenMemHandle = (cuIpcOpenMemHandle_t)fnptr;
27}
28
29static
30CUresult call_cuIpcOpenMemHandle(CUdeviceptr* pdptr, CUipcMemHandle* handle, unsigned int flags)
31{
32 return cuIpcOpenMemHandle(pdptr, *handle, flags);
33}
34
35
36MOD_INIT(_extras)PyObject* PyInit__extras(void) {
37 PyObject *m;
38 MOD_DEF(m, "_extras", "No docs", NULL){ static struct PyModuleDef moduledef = { { { 1, ((void*)0) }
, ((void*)0), 0, ((void*)0), }, "_extras", "No docs", -1, ((void
*)0), ((void*)0), ((void*)0), ((void*)0), ((void*)0) }; m = PyModule_Create2
(&moduledef, 1013); }
39 if (m == NULL((void*)0))
1
Assuming 'm' is not equal to NULL
2
Taking false branch
40 return MOD_ERROR_VAL((void*)0);
41 PyModule_AddObject(m, "set_cuIpcOpenMemHandle", PyLong_FromVoidPtr(&set_cuIpcOpenMemHandle));
42 PyModule_AddObject(m, "call_cuIpcOpenMemHandle", PyLong_FromVoidPtr(&call_cuIpcOpenMemHandle));
3
Calling 'PyLong_FromVoidPtr'
5
Returning from 'PyLong_FromVoidPtr'
6
PyObject ownership leak with reference count of 1
43 PyModule_AddIntConstant(m, "CUDA_IPC_HANDLE_SIZE", CUDA_IPC_HANDLE_SIZE64);
44 return MOD_SUCCESS_VAL(m)m;
45}

/opt/pyrefcon/lib/pyrefcon/models/models/PyLong_FromVoidPtr.model

1#ifndef PyLong_FromVoidPtr
2PyObject* clang_analyzer_PyObject_New_Reference();
3PyObject* PyLong_FromVoidPtr(void *p) {
4 return clang_analyzer_PyObject_New_Reference();
4
Setting reference count to 1
5}
6#else
7#warning "API PyLong_FromVoidPtr is defined as a macro."
8#endif