Bug Summary

File:.cache/bazel/_bazel_alan/39be661231df2a680c9b74265384c13c/execroot/org_tensorflow/tensorflow/python/framework/python_api_parameter_converter_wrapper.cc
Warning:line 33, 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 python_api_parameter_converter_wrapper.cc -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/tensorflow/csa-scan,ctu-index-name=/tmp/pyrefcon/tensorflow/csa-scan/externalDefMap.txt,ctu-invocation-list=/tmp/pyrefcon/tensorflow/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=all -relaxed-aliasing -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/home/pyrefcon/.cache/bazel/_bazel_alan/39be661231df2a680c9b74265384c13c/execroot/org_tensorflow -resource-dir /opt/pyrefcon/lib/clang/13.0.0 -iquote . -iquote bazel-out/k8-opt/bin -iquote external/com_google_absl -iquote bazel-out/k8-opt/bin/external/com_google_absl -iquote external/pybind11 -iquote bazel-out/k8-opt/bin/external/pybind11 -iquote external/local_config_python -iquote bazel-out/k8-opt/bin/external/local_config_python -iquote external/com_google_protobuf -iquote bazel-out/k8-opt/bin/external/com_google_protobuf -iquote external/nsync -iquote bazel-out/k8-opt/bin/external/nsync -iquote external/eigen_archive -iquote bazel-out/k8-opt/bin/external/eigen_archive -iquote external/gif -iquote bazel-out/k8-opt/bin/external/gif -iquote external/libjpeg_turbo -iquote bazel-out/k8-opt/bin/external/libjpeg_turbo -iquote external/com_googlesource_code_re2 -iquote bazel-out/k8-opt/bin/external/com_googlesource_code_re2 -iquote external/farmhash_archive -iquote bazel-out/k8-opt/bin/external/farmhash_archive -iquote external/fft2d -iquote bazel-out/k8-opt/bin/external/fft2d -iquote external/highwayhash -iquote bazel-out/k8-opt/bin/external/highwayhash -iquote external/zlib -iquote bazel-out/k8-opt/bin/external/zlib -iquote external/bazel_tools -iquote bazel-out/k8-opt/bin/external/bazel_tools -isystem external/pybind11/include -isystem bazel-out/k8-opt/bin/external/pybind11/include -isystem /opt/pyrefcon/lib/pyrefcon/models/python3.8 -isystem /opt/pyrefcon/lib/pyrefcon/models/python3.8 -isystem external/com_google_protobuf/src -isystem bazel-out/k8-opt/bin/external/com_google_protobuf/src -isystem external/nsync/public -isystem bazel-out/k8-opt/bin/external/nsync/public -isystem third_party/eigen3/mkl_include -isystem bazel-out/k8-opt/bin/third_party/eigen3/mkl_include -isystem external/eigen_archive -isystem bazel-out/k8-opt/bin/external/eigen_archive -isystem external/gif -isystem bazel-out/k8-opt/bin/external/gif -isystem external/farmhash_archive/src -isystem bazel-out/k8-opt/bin/external/farmhash_archive/src -isystem external/zlib -isystem bazel-out/k8-opt/bin/external/zlib -isystem external/local_config_python/numpy_include -isystem bazel-out/k8-opt/bin/external/local_config_python/numpy_include -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=1 -D NDEBUG -D EIGEN_MPL2_ONLY -D EIGEN_MAX_ALIGN_BYTES=64 -I bazel-out/k8-opt/bin/external/pybind11/_virtual_includes/pybind11 -D AUTOLOAD_DYNAMIC_KERNELS -D __DATE__="redacted" -D __TIMESTAMP__="redacted" -D __TIME__="redacted" -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 -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -Wno-builtin-macro-redefined -w -std=c++14 -fdeprecated-macro -fdebug-compilation-dir=/home/pyrefcon/.cache/bazel/_bazel_alan/39be661231df2a680c9b74265384c13c/execroot/org_tensorflow -ferror-limit 19 -fvisibility hidden -stack-protector 1 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/pyrefcon/tensorflow/csa-scan/reports -x c++ tensorflow/python/framework/python_api_parameter_converter_wrapper.cc

tensorflow/python/framework/python_api_parameter_converter_wrapper.cc

1/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15// Note: This library is only used by python_api_parameter_converter_test. It
16// is not meant to be used in other circumstances.
17
18#include "pybind11/pybind11.h"
19#include "pybind11/pytypes.h"
20#include "pybind11/stl.h"
21#include "tensorflow/python/framework/python_api_parameter_converter.h"
22
23namespace py = pybind11;
24
25namespace tensorflow {
26namespace {
27
28PythonAPIInfo::InferredAttributes Convert(
29 const PythonAPIInfo& api_info,
30 const PythonTensorConverter& tensor_converter, py::handle arg_list) {
31 PythonAPIInfo::InferredAttributes inferred_attrs;
32
33 PyObject* args_fast = PySequence_Fast(arg_list.ptr(), "Expected a list");
1
Calling 'PySequence_Fast'
3
Returning from 'PySequence_Fast'
7
PyObject ownership leak with reference count of 1
34 absl::Span<PyObject*> args_raw(PySequence_Fast_ITEMS(args_fast)(((((((PyObject*)(args_fast))->ob_type))->tp_flags &
((1UL << 25))) != 0) ? ((PyListObject *)(args_fast))->
ob_item : ((PyTupleObject *)(args_fast))->ob_item)
,
4
Assuming the condition is true
5
'?' condition is true
35 PySequence_Fast_GET_SIZE(args_fast)(((((((PyObject*)(args_fast))->ob_type))->tp_flags &
((1UL << 25))) != 0) ? ((static_cast<void> (0)),
(((PyVarObject*)(args_fast))->ob_size)) : (((PyVarObject*
)(((static_cast<void> (0)), (PyTupleObject *)(args_fast
))))->ob_size))
);
6
'?' condition is true
36
37 if (!CopyPythonAPITensorLists(api_info, args_raw)) {
38 throw py::error_already_set();
39 }
40 if (!ConvertPythonAPIParameters(api_info, tensor_converter, args_raw,
41 &inferred_attrs)) {
42 throw py::error_already_set();
43 }
44
45 return inferred_attrs;
46}
47
48} // namespace
49} // namespace tensorflow
50
51PYBIND11_MODULE(_pywrap_python_api_parameter_converter, m)static ::pybind11::module_::module_def pybind11_module_def__pywrap_python_api_parameter_converter
; __attribute__ ((__unused__)) static void pybind11_init__pywrap_python_api_parameter_converter
(::pybind11::module_ &); extern "C" __attribute__ ((__unused__
)) __attribute__ ((visibility("default"))) PyObject *PyInit__pywrap_python_api_parameter_converter
(); extern "C" __attribute__ ((visibility("default"))) PyObject
*PyInit__pywrap_python_api_parameter_converter() { { const char
*compiled_ver = "3" "." "8"; const char *runtime_ver = Py_GetVersion
(); size_t len = std::strlen(compiled_ver); if (std::strncmp(
runtime_ver, compiled_ver, len) != 0 || (runtime_ver[len] >=
'0' && runtime_ver[len] <= '9')) { PyErr_Format(PyExc_ImportError
, "Python version mismatch: module was compiled for Python %s, "
"but the interpreter version is incompatible: %s.", compiled_ver
, runtime_ver); return nullptr; } } pybind11::detail::get_internals
(); auto m = ::pybind11::module_::create_extension_module( "_pywrap_python_api_parameter_converter"
, nullptr, &pybind11_module_def__pywrap_python_api_parameter_converter
); try { pybind11_init__pywrap_python_api_parameter_converter
(m); return m.ptr(); } catch (pybind11::error_already_set &
e) { PyErr_SetString(PyExc_ImportError, e.what()); return nullptr
; } catch (const std::exception &e) { PyErr_SetString(PyExc_ImportError
, e.what()); return nullptr; } } void pybind11_init__pywrap_python_api_parameter_converter
(::pybind11::module_ &m)
{
52 m.def("Convert", tensorflow::Convert);
53}

/opt/pyrefcon/lib/pyrefcon/models/models/PySequence_Fast.model

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