Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valgrind reports leak when constructing TChain #13130

Open
1 task done
Tracked by #14319
vepadulano opened this issue Jun 30, 2023 · 8 comments
Open
1 task done
Tracked by #14319

Valgrind reports leak when constructing TChain #13130

vepadulano opened this issue Jun 30, 2023 · 8 comments

Comments

@vepadulano
Copy link
Member

vepadulano commented Jun 30, 2023

Check duplicate issues.

  • Checked for duplicates

Description

I see definitely lost: 8,904 bytes in 76 blocks with valgrind in a few different places, which apparently all boil down to the following series of calls

==174298==    at 0x484382F: malloc (vg_replace_malloc.c:431)
==174298==    by 0xB8A21C5: llvm::safe_malloc(unsigned long) (MemAlloc.h:26)
==174298==    by 0xB8A2ACC: clang::TemplateIdAnnotation::Create(clang::SourceLocation, clang::SourceLocation, clang::IdentifierInfo*, clang::OverloadedOperatorKind, clang::OpaquePtr<clang::TemplateName>, clang::TemplateNameKind, clang::SourceLocation, clang::SourceLocation, llvm::ArrayRef<clang::ParsedTemplateArgument>, bool, llvm::SmallVectorImpl<clang::TemplateIdAnnotation*>&) (ParsedTemplate.h:206)
==174298==    by 0xB90CA4B: clang::Parser::AnnotateTemplateIdToken(clang::OpaquePtr<clang::TemplateName>, clang::TemplateNameKind, clang::CXXScopeSpec&, clang::SourceLocation, clang::UnqualifiedId&, bool, bool) (ParseTemplate.cpp:1356)
==174298==    by 0xB893CA9: clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&, clang::OpaquePtr<clang::QualType>, bool, bool, bool*, bool, clang::IdentifierInfo**, bool, bool) (ParseExprCXX.cpp:506)
==174298==    by 0xB91DDED: clang::Parser::TryAnnotateCXXScopeToken(bool) (Parser.cpp:2094)
==174298==    by 0xA8FB2A9: cling::LookupHelper::findScope(llvm::StringRef, cling::LookupHelper::DiagSetting, clang::Type const**, bool) const (LookupHelper.cpp:629)
==174298==    by 0xA7FF96C: TClingClassInfo::TClingClassInfo(cling::Interpreter*, char const*, bool) (TClingClassInfo.cxx:87)

Full report from valgrind
valgrind_report.txt

Reproducer

ROOT was built with the following configuration

cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DLLVM_BUILD_TYPE=Debug

This is the reproducer

#include <TChain.h>
int main(){
    TChain c;
}

Compile and run with valgrind

$: g++ -g -o repro.out repro.cpp `root-config --cflags --glibs`
$: valgrind --leak-check=full --num-callers=30 --suppressions=$ROOTSYS/etc/valgrind-root.supp ./repro.out

ROOT version

master@1be2785

Installation method

built from source

Operating system

Fedora 37

Additional context

Compiler: GCC 12

I have arrived to the minimal reproducer above starting from the code in RSample.cxx which creates a temporary TChain in the constructor.

@eguiraud
Copy link
Member

eguiraud commented Jul 3, 2023

This is likely something to be added to the suppression file: jitting allocates and never deallocates.

@vgvassilev
Copy link
Member

Indeed, @pcanal invested a lot of time to avoid these cases but we still have to allocate some memory on making lookups.

@Axel-Naumann
Copy link
Member

This isn't jitting, and clang should not leak this. Please leave it open for me to look at in a couple of weeks. Thanks for the report!

@ferdymercury
Copy link
Collaborator

I get 0 bytes lost on Ubuntu 22.04 and 3b06c87 (valgrind 3.18)

@AxelKrypton
Copy link

Just for the records, working with a software that uses ROOT as a library and switching on the address sanitiser in our unit tests, we get the following report with all 6.28.XX versions:

==15==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8792 byte(s) in 75 object(s) allocated from:
    #0 0x7ff05e914887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7ff04609ad21 in clang::Parser::AnnotateTemplateIdToken(clang::OpaquePtr<clang::TemplateName>, clang::TemplateNameKind, clang::CXXScopeSpec&, clang::SourceLocation, clang::UnqualifiedId&, bool, bool) (/SMASH/root_install/lib/libCling.so+0x15b5d21)

SUMMARY: AddressSanitizer: 8792 byte(s) leaked in 75 allocation(s).

Using ROOT 6.26.10 does not display the problem.

I am not sure this is exactly the same problem of this issue, but I did not want to open a new issue at first as in the description clang::Parser::AnnotateTemplateIdToken is part of the Valgrind output. If you need more information from my side, feel free to ask.

@Axel-Naumann
Copy link
Member

Thanks - could you

  • open a dedicated issue for this
  • share way way more of the backtrace: ideally everything but at least until the first frame in TCling.

Thanks for investing your time here!

@dpiparo
Copy link
Member

dpiparo commented Feb 5, 2024

@vepadulano , not clear from the conversation to me, but is the comment above about the suppression file and how cling allocates addressing your original issue? If yes,could you close this item?

@ferdymercury
Copy link
Collaborator

ferdymercury commented Feb 27, 2024

This seems another occurrence: https://root-forum.cern.ch/t/memory-leak-during-repeated-fitting/58299/16 that also gets solved when going into 6.30. So maybe a backport for 6.28 would be useful.

@ferdymercury ferdymercury added this to Issues in Fixed in 6.32.00 via automation Feb 27, 2024
@ferdymercury ferdymercury added this to Issues in Fixed in 6.30.06 via automation Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

7 participants