Skip to content

[bindings] Clang-Tidy Clazy Analyzer leaks / bugs report #7400

@ferdymercury

Description

@ferdymercury

Describe the bug

I compile ROOT using QtCreator, which has an embedded Clang and Tidy Analyzer. After a couple of hours of analysis, I get a report with many warnings.

  • Some of them look unimportant
  • Some of them could be auto-fixed by Clang
  • Some of them look like real errors.

For example, in the file clingwrapper.cxx, obj is not deleted if WrapperCall returns false, which seems to lead to a leak:

Cppyy::TCppObject_t Cppyy::CallO(TCppMethod_t method,
    TCppObject_t self, size_t nargs, void* args, TCppType_t result_type)
{
    TClassRef& cr = type_from_handle(result_type);
    void* obj = ::operator new(gInterpreter->ClassInfo_Size(cr->GetClassInfo()));
    if (WrapperCall(method, nargs, args, self, obj))
        return (TCppObject_t)obj;
    return (TCppObject_t)0;
}
/opt/root_src/bindings/pyroot/cppyy/cppyy-backend/clingwrapper/src/clingwrapper.cxx:889:26: warning: Potential leak of memory pointed to by 'obj' [clang-analyzer-cplusplus.NewDeleteLeaks]
 1: Calling 'CallO' in /opt/root_src/bindings/pyroot/cppyy/cppyy-backend/clingwrapper/src/clingwrapper.cxx:2290
 2: Memory is allocated in /opt/root_src/bindings/pyroot/cppyy/cppyy-backend/clingwrapper/src/clingwrapper.cxx:886
 3: Taking false branch in /opt/root_src/bindings/pyroot/cppyy/cppyy-backend/clingwrapper/src/clingwrapper.cxx:887
 4: Potential leak of memory pointed to by 'obj' in /opt/root_src/bindings/pyroot/cppyy/cppyy-backend/clingwrapper/src/clingwrapper.cxx:889

My question is: how should I report them? In separate issues for each CMake subdirectory? All in the same Ticket? Or do the devs prefer to run it by themselves for easier check?

Concerning things as "0 as nullptr", would you accept a PR that fixes all of these across ROOT at the same time, see here https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html, or you prefer to keep with the old convention of using 0 ?

To Reproduce

  • Install QtCreator
  • Click on File, Import File or Project, click on the main CMakeLists.txt of the ROOT source git repository.
  • Build
  • Tool, Run Clang & Tidy Analyzer

Setup

  1. ROOT 6.23/01
  2. Ubuntu 18
  3. git master

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions