Problem interpreting valgrind results

Dear ROOTers

I am testing my programm for memory problems using valgrind and get a lot of messages involving both my
program and ROOT. I must admit that I do not know what causes these messages. Here is an example:

==10578== 32 bytes in 1 blocks are definitely lost in loss record 95 of 269
==10578==    at 0x40277EE: operator new(unsigned) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10578==    by 0x90C4E1B: _ZN4ROOTL13new_XGCSchemeEPv (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578==    by 0x41FCDBA: TClass::New(TClass::ENewType) const (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10578==    by 0x95287A1: TBranchElement::SetAddress(void*) (in /home/rabbitus/ROOT/root/lib/libTree.so)
==10578==    by 0x956F1D0: TTree::SetBranchAddress(char const*, void*, TBranch**) (in /home/rabbitus/ROOT/root/lib/libTree.so)
==10578==    by 0x9566DBC: TTree::SetBranchAddress(char const*, void*, TBranch**, TClass*, EDataType, bool) (in /home/rabbitus/ROOT/root/lib/libTree.so)
==10578==    by 0x907D086: XGCProcesSet::SchemeMask(XDNAChip*, int, int, int*) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578==    by 0x908DB7A: XGCProcesSet::AdjustBackground(int, TTree**, int&, TTree**) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578==    by 0x908F296: XGCProcesSet::Preprocess(char const*) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578==    by 0x907E70E: XPreProcessManager::Preprocess(char const*, char const*) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578==    by 0x924A776: _ZL18G__xpsDict_702_0_7P8G__valuePKcP8G__parami (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578==    by 0x47B08D5: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /home/rabbitus/ROOT/root/lib/libCint.so)

As far as I understand the message, the problem is in this method:

Int_t XGCProcesSet::SchemeMask(XDNAChip *chip, Int_t level, Int_t n, Int_t *msk)
{
   Int_t err = errNoErr;

   TDirectory *savedir = gDirectory;
   if (!fSchemeFile->cd(fSchemeName)) return errGetDir;

   XScheme *scheme = 0;
   TTree *scmtree = (TTree*)gDirectory->Get(chip->GetSchemeTree()); 
   if (scmtree == 0) return errGetTree;
   scmtree->SetBranchAddress("ScmBranch", &scheme);

   msk = this->FillMaskArray(chip, scmtree, scheme, level, n, msk);

   // delete scheme tree from RAM
   if (scmtree) {scmtree->Delete(""); scmtree = 0;}

   savedir->cd();

   return err;
}//SchemeMask

Can you tell me what might cause the valgrind message?

What does the first line mean:

==10578==    at 0x40277EE: operator new(unsigned) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)

Since a couple of error messages seem to involve ROOT, I am attaching the complete valgrind output as
file “valgrind_Test3_mas5.txt”. Interestingly, the number of ROOT-related error messages increases when
I run the same example from within “R” as an R-package. Thus I am also enclosing the complete valgrind
output from the R-session as file “valgrind_Test3_mas5_R.txt”.

It would be great if you could give me a hint where to search for the memory problems and what the
ROOT-related messages mean.

Thank you in advance.

Best regards
Christian
valgrind_Test3_mas5_R.txt (56.6 KB)
valgrind_Test3_mas5.txt (26.8 KB)

==10578== at 0x40277EE: operator new(unsigned) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so) ==10578== by 0x90C4E1B: _ZN4ROOTL13new_XGCSchemeEPv (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so) Does indicate a memory leak. Which version of ROOT are you using? (It should be fixed in v5.22). Either way, you can fixed by explicitly deleting this memory. Also do not (in general) use mytree->Delete (The Delete function is for collections). So the end of your function should look like: // delete scheme tree from RAM delete scheme; scheme = 0; delete schemetree; schmetree = 0;

Cheers,
Philippe.

Hi Christian,

You can ignore the reports:==28238== Conditional jump or move depends on uninitialised value(s) ==28238== at 0x81D756B: longest_match (deflate.c:1107) ==28238== by 0x81D8E39: deflate_fast (deflate.c:1470)
The error==28238== ==28238== Invalid read of size 4 ==28238== at 0x678D47A: TList::Clear(char const*) (in /home/rabbitus/ROOT/root/lib/libCore.so) ==28238== by 0x678E0C9: TList::~TList() (in /home/rabbitus/ROOT/root/lib/libCore.so) ==28238== by 0x620043F: XTreeSet::~XTreeSet() (in /home/rabbitus/CRAN/R/myRlib/xps/libs/xps.so) ==28238== by 0x627B094: XProcesSet::~XProcesSet() (in /home/rabbitus/CRAN/R/myRlib/xps/libs/xps.so) ==28238== by 0x62AF80B: XNormedSet::~XNormedSet() (in /home/rabbitus/CRAN/R/myRlib/xps/libs/xps.so) ==28238== by 0x62AF84C: XNormedGCSet::~XNormedGCSet() (in /home/rabbitus/CRAN/R/myRlib/xps/libs/xps.so) ==28238== by 0x6791D46: TObjectTable::Delete(char const*) (in /home/rabbitus/ROOT/root/lib/libCore.so) ==28238== by 0x67875AC: TCollection::EmptyGarbageCollection() (in /home/rabbitus/ROOT/root/lib/libCore.so) ==28238== by 0x6715FA0: TFolder::~TFolder() (in /home/rabbitus/ROOT/root/lib/libCore.so) ==28238== by 0x61FBF8A: XFolder::~XFolder() (in /home/rabbitus/CRAN/R/myRlib/xps/libs/xps.so) ==28238== by 0x6202C35: XManager::Close(char const*) (in /home/rabbitus/CRAN/R/myRlib/xps/libs/xps.so) ==28238== by 0x627C9D0: XProcessManager::Close(char const*) (in /home/rabbitus/CRAN/R/myRlib/xps/libs/xps.so) ==28238== Address 0xa0902e0 is 8 bytes inside a block of size 372 free'd ==28238== at 0x402679A: operator delete(void*) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so) ==28238== by 0x6740E72: TStorage::ObjectDealloc(void*) (in /home/rabbitus/ROOT/root/lib/libCore.so) ==28238== by 0x671E887: TObject::operator delete(void*) (in /home/rabbitus/ROOT/root/lib/libCore.so) ==28238== by 0x7F186CB: TTree::~TTree() (in /home/rabbitus/ROOT/root/lib/libTree.so) ==28238== by 0x678742C: TCollection::GarbageCollect(TObject*) (in /home/rabbitus/ROOT/root/lib/libCore.so) ==28238== by 0x678D36D: TList::Delete(char const*) (in /home/rabbitus/ROOT/root/lib/libCore.so) ==28238== by 0x627AFBA: XProcesSet::~XProcesSet() (in /home/rabbitus/CRAN/R/myRlib/xps/libs/xps.so) ==28238== by 0x62AF80B: XNormedSet::~XNormedSet() (in /home/rabbitus/CRAN/R/myRlib/xps/libs/xps.so) ==28238== by 0x62AF84C: XNormedGCSet::~XNormedGCSet() (in /home/rabbitus/CRAN/R/myRlib/xps/libs/xps.so) ==28238== by 0x6791D46: TObjectTable::Delete(char const*) (in /home/rabbitus/ROOT/root/lib/libCore.so) ==28238== by 0x67875AC: TCollection::EmptyGarbageCollection() (in /home/rabbitus/ROOT/root/lib/libCore.so) ==28238== by 0x6715FA0: TFolder::~TFolder() (in /home/rabbitus/ROOT/root/lib/libCore.so)should be investigated. It looks like you XTreeSet object and your XProcessSet are both pointed (and attempting to delete) the same object(s).

[code]==28238== 2 bytes in 1 blocks are definitely lost in loss record 3 of 203
==28238== at 0x402710E: operator new (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==28238== by 0x62D86C3: PreprocessMAS5 (in /home/rabbitus/CRAN/R/myRlib/xps/libs/xps.so)
==28238== by 0x817569B: do_dotCode (dotcode.c:1776)

==28238== 12 bytes in 2 blocks are definitely lost in loss record 58 of 203
==28238== at 0x402710E: operator new (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==28238== by 0x62D086A: ChipNameType (in /home/rabbitus/CRAN/R/myRlib/xps/libs/xps.so)
==28238== by 0x8171D6E: do_dotCode (dotcode.c:1729)

==28238== 14 bytes in 1 blocks are definitely lost in loss record 59 of 203
==28238== at 0x402710E: operator new (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==28238== by 0x62D1D90: Normxpress (in /home/rabbitus/CRAN/R/myRlib/xps/libs/xps.so)
==28238== by 0x817219A: do_dotCode (dotcode.c:1810)

==10578== 112 bytes in 4 blocks are definitely lost in loss record 137 of 269
==10578== at 0x40277EE: operator new(unsigned) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10578== by 0x908DF1E: XGCProcesSet::AdjustBackground(int, TTree**, int&, TTree**) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x908F296: XGCProcesSet::Preprocess(char const*) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x907E70E: XPreProcessManager::Preprocess(char const*, char const*) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x924A776: _ZL18G__xpsDict_702_0_7P8G__valuePKcP8G__parami (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x47B08D5: Cint::G__ExceptionWrapper(int ()(G__value, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x486679B: G__execute_call (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x48678F5: G__call_cppfunc (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x483DFEB: G__interpret_func (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x482D723: G__getfunction (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x491BC60: G__getstructmem (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x491537D: G__getvariable (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578==
==10578==
==10578== 112 bytes in 4 blocks are definitely lost in loss record 138 of 269
==10578== at 0x40277EE: operator new(unsigned) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10578== by 0x9091BFD: XGCProcesSet::DoExpress(int, TTree**, int, TTree**) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x908B664: XGCProcesSet::Express(int, TTree**, int&, TTree**) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x908F680: XGCProcesSet::Preprocess(char const*) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x907E70E: XPreProcessManager::Preprocess(char const*, char const*) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x924A776: _ZL18G__xpsDict_702_0_7P8G__valuePKcP8G__parami (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x47B08D5: Cint::G__ExceptionWrapper(int ()(G__value, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x486679B: G__execute_call (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x48678F5: G__call_cppfunc (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x483DFEB: G__interpret_func (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x482D723: G__getfunction (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x491BC60: G__getstructmem (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578==
==10578==
==10578== 128 bytes in 4 blocks are definitely lost in loss record 140 of 269
==10578== at 0x40277EE: operator new(unsigned) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10578== by 0x908658C: XGCProcesSet::FillDataTree(TTree*, char const*, XAlgorithm*, int, int, double*, double*) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x908E40F: XGCProcesSet::AdjustBackground(int, TTree**, int&, TTree**) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x908F296: XGCProcesSet::Preprocess(char const*) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x907E70E: XPreProcessManager::Preprocess(char const*, char const*) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x924A776: _ZL18G__xpsDict_702_0_7P8G__valuePKcP8G__parami (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10578== by 0x47B08D5: Cint::G__ExceptionWrapper(int ()(G__value, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x486679B: G__execute_call (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x48678F5: G__call_cppfunc (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x483DFEB: G__interpret_func (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x482D723: G__getfunction (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10578== by 0x491BC60: G__getstructmem (in /home/rabbitus/ROOT/root/lib/libCint.so)

[/code]are likely to be memory leak in the xps code.

All reports listing a G__memfunc_setup, G__RegisterLibrary, TStreamerInfo::Compile, TClass::GetStreamerInfo functions should be ignored (they are not memory leak but memory that we intentionally do not delete are processed end time to save run-time).

Cheers,
Philippe.

Dear Philippe

Thank you for your replies.
Please allow me to answer at the moment to your first reply, since this is very important for me.

The following code fragment is scattered all over my program:

Int_t MyFunction()
{
   MyClass *myclass = 0;
   TTree *tree = (TTree*)gDirectory->Get("mytree");
   tree->SetBranchAddress("MyBranch", &myclass);

   // delete scheme tree from RAM
   tree->Delete(""); tree = 0;

   return err;
}

Thus it is very important for me to know the answers to the following questions:

1., Since I never do “delete myclass” after setting “myclass = 0” the most important question is:
Does not deleting myclass really result in memory leaks and why?

2., If it results in memory leaks, why does valgrind only detect three cases and not all the other cases?

3., Neither the ROOT class documentation nor the ROOT UserGuide mention that this is necessary.

4., The few tutorials which use a class for SetBranchAdress, namely “tree2a.C”, "portfolio.C"
and “jets.C”, are also wrong since they do not delete the corresponding class.

5., I could only find one ROOT method, where the class is deleted, but in this method it is created
first with “new”, this is method “TMVA::MethodKNN::ReadWeightsFromStream(TFile &rf)”, e.g.:

Int_t MyFunction()
{
   MyClass *myclass = new MyClass();

   tree->SetBranchAddress("MyBranch", &myclass);

   delete myclass;   
}

In this case it is clear that myclass must be deleted.
However, if I remember correctly, this is not recommended. Is this correct?

6., I have often the case that I pass trees as parameter to diverse methods, e.g.:

Int_t MyFunction1(TTree *mytree)
{
   MyClass *myclass = 0;

   mytree->SetBranchAddress("MyBranch", &myclass);

//??   delete myclass;   
}

Int_t MyFunction2(TTree *mytree)
{
   MyClass *myclass = 0;

   mytree->SetBranchAddress("MyBranch", &myclass);

//??   delete myclass;   
}

Int_t main()
{
   TTree *mytree = new TTree();

   err =  MyFunction1(mytree);
   err =  MyFunction2(mytree);

   delete mytree;
}

I assume that when I do “delete myclass;” in MyFunction1() then MyFunction2() will no longer work.
Is this correct?

  1. Is it not allowed to use “tree->Delete(”")" or not recommended?
    Why does then the reference guide for TTree::Delete() say:
    “if option ==”" only Tree object in memory is deleted."

BTW, I am using ROOT version root_5.22/00.
What do you mean with “It should be fixed in v5.22”?
Which error should be fixed in this version?

Best regards
Christian

Hi Christian,

Prior to ROOT v5.20 (see the releases notes of v5.20 for the details), the TTree could not delete the user object even when it created it. This leads to a (often small) memory leak of one object per tree per top level branch.

In v5.20, the TTree now deletes the user object if it has created it.

So the short answer to your ‘BTW’, 1, 3, 4 is simply that the ‘bug’ was the existence of the leak (and the lack of ‘handling’ this leak in the tutorials) :slight_smile:.

For 5., since the user has allocated the object, the convention is that the user must delete it (This is because the TTree can not know ‘how’ the object was allocated and the object maybe on the stack (rather than the head).

For 7. tree->Delete("") is just not recommended. The C++ code is clearer it is reading ‘delete tree;’

For 6 (and hence probably 2).
The pattern:Int_t MyFunction1(TTree *mytree) { MyClass *myclass = 0; mytree->SetBranchAddress("MyBranch", &myclass); .... }is very bad. The TTree ‘records’ the address being passed (the &myclass). When the function exit, the ‘myclass pointer’ goes away and now the TTree points to ‘random memory’. More over, the TTree use this pointer to hold the address of the object (once it created it). So since this memory now becomes random, it is likely to lose track of the pointer. In your example, what actually happens is upon the call of MyFunction2, the compiler/run-time puts MyFunction2’s myclass variable is exactly the same place as where MyFunction1’s myclass variable was and then initialize it to zero. Since the TTree still ‘remembers/uses’ the now-vanished MyFunction1’s myclass variable to remember where is the user object, the execution of MyFunction2’s ‘myclass = 0;’ has the net effect of telling the TTree to ‘forget’ about the object. and hence when the
2nd SetBranchAddress is executed, it will not (since it does not about it anymore) delete the user object … lead to a memory leak.

Of course, in this case, you are actually ‘lucky’ that it is ‘only’ a memory leak. In more complex case, the 2 pointer may not overlap and the content of the ‘now-vanished MyFunction1’s myclass’ may instead have been set to some other bit pattern (than 0) and lead to a segmentation fault when the 2nd SetBranchAddress attempted to delete the user object.

To avoid this whole mess :slight_smile:, you need do:Int_t MyFunction1(TTree *mytree) { MyClass *myclass = 0; mytree->SetBranchAddress("MyBranch", &myclass); ... // And now forget about the local pointer. mytree->ResetBranchAddress(mytree->GetBranch("MyBranch")); // or mytree->ResetBranchAddresses(); }

You can also explicitly delete the object, but you must inform the TTree by setting the value of pointer:Int_t MyFunction1(TTree *mytree) { MyClass *myclass = 0; mytree->SetBranchAddress("MyBranch", &myclass); ... delete myclass; myclass = 0; // And now forget about the local pointer. mytree->ResetBranchAddress(mytree->GetBranch("MyBranch")); // or mytree->ResetBranchAddresses(); }

Cheers,
Philippe.

Dear Philippe

Thank you for your extensive reply, and for the code how to avoid the problems.
I will change my code and test it, and will let you know if this solved the memory problems.

Best regards
Christian

Dear Philippe

I have now (hopefully) eliminated all memory leaks, but the following valgrind messages remain:

==10730== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 577 from 4)
==10730== malloc/free: in use at exit: 6,817,206 bytes in 100,434 blocks.
==10730== malloc/free: 989,129 allocs, 888,695 frees, 79,623,405 bytes allocated.
==10730== For counts of detected errors, rerun with: -v
==10730== searching for pointers to 100,434 not-freed blocks.
==10730== checked 10,260,948 bytes.
==10730== 
==10730== 2 bytes in 1 blocks are definitely lost in loss record 4 of 263
==10730==    at 0x4027DDE: malloc (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10730==    by 0x4874D9D: G__memfunc_para_setup (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x48751A0: G__parse_parameter_link (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x48755B4: G__memfunc_setup_imp (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x4875EF7: G__memfunc_setup (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x4F33274: G__cpp_setup_funcG__Math (in /home/rabbitus/ROOT/root/lib/libMathCore.so)
==10730==    by 0x4F33CA4: G__cpp_setupG__Math (in /home/rabbitus/ROOT/root/lib/libMathCore.so)
==10730==    by 0x484E010: G__call_setup_funcs (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x484E211: G__main (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x485046F: G__init_cint (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x422CAA6: TCint::ResetAll() (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x422CC44: TCint::TCint(char const*, char const*) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730== 
==10730== 
==10730== 40 bytes in 1 blocks are definitely lost in loss record 91 of 263
==10730==    at 0x4027DDE: malloc (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10730==    by 0x4852ADC: G__register_sharedlib (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x48E2C06: G__RegisterLibrary (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x48506F3: G__add_setup_func (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x505CFCD: G__cpp_setup_initG__Rint::G__cpp_setup_initG__Rint() (in /home/rabbitus/ROOT/root/lib/libRint.so)
==10730==    by 0x505C532: __static_initialization_and_destruction_0(int, int) (in /home/rabbitus/ROOT/root/lib/libRint.so)
==10730==    by 0x505C576: _GLOBAL__I_G__Rint.cxx (in /home/rabbitus/ROOT/root/lib/libRint.so)
==10730==    by 0x505D39C: (within /home/rabbitus/ROOT/root/lib/libRint.so)
==10730==    by 0x5042FF7: (within /home/rabbitus/ROOT/root/lib/libRint.so)
==10730==    by 0x400EDB3: (within /lib/ld-2.9.so)
==10730==    by 0x400EEE3: (within /lib/ld-2.9.so)
==10730==    by 0x400088E: (within /lib/ld-2.9.so)
==10730== 
==10730== 
==10730== 60 (28 direct, 32 indirect) bytes in 1 blocks are definitely lost in loss record 92 of 263
==10730==    at 0x4027DDE: malloc (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10730==    by 0x487557E: G__memfunc_setup_imp (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x4875EF7: G__memfunc_setup (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x4F33274: G__cpp_setup_funcG__Math (in /home/rabbitus/ROOT/root/lib/libMathCore.so)
==10730==    by 0x4F33CA4: G__cpp_setupG__Math (in /home/rabbitus/ROOT/root/lib/libMathCore.so)
==10730==    by 0x484E010: G__call_setup_funcs (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x4F3A4AB: _GLOBAL__I_G__Math.cxx (in /home/rabbitus/ROOT/root/lib/libMathCore.so)
==10730==    by 0x4FEF56C: (within /home/rabbitus/ROOT/root/lib/libMathCore.so)
==10730==    by 0x4ED3EA7: (within /home/rabbitus/ROOT/root/lib/libMathCore.so)
==10730==    by 0x400EDB3: (within /lib/ld-2.9.so)
==10730==    by 0x400EEE3: (within /lib/ld-2.9.so)
==10730==    by 0x400088E: (within /lib/ld-2.9.so)
==10730== 
==10730== 
==10730== 61 (60 direct, 1 indirect) bytes in 1 blocks are definitely lost in loss record 111 of 263
==10730==    at 0x4027DDE: malloc (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10730==    by 0x4852A87: G__register_sharedlib (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x48E2C06: G__RegisterLibrary (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x48506F3: G__add_setup_func (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x505CFCD: G__cpp_setup_initG__Rint::G__cpp_setup_initG__Rint() (in /home/rabbitus/ROOT/root/lib/libRint.so)
==10730==    by 0x505C532: __static_initialization_and_destruction_0(int, int) (in /home/rabbitus/ROOT/root/lib/libRint.so)
==10730==    by 0x505C576: _GLOBAL__I_G__Rint.cxx (in /home/rabbitus/ROOT/root/lib/libRint.so)
==10730==    by 0x505D39C: (within /home/rabbitus/ROOT/root/lib/libRint.so)
==10730==    by 0x5042FF7: (within /home/rabbitus/ROOT/root/lib/libRint.so)
==10730==    by 0x400EDB3: (within /lib/ld-2.9.so)
==10730==    by 0x400EEE3: (within /lib/ld-2.9.so)
==10730==    by 0x400088E: (within /lib/ld-2.9.so)
==10730== 
==10730== 
==10730== 200 bytes in 1 blocks are definitely lost in loss record 145 of 263
==10730==    at 0x402710E: operator new[](unsigned) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10730==    by 0x41DA0F9: TArrayI::Set(int) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x4163C2D: TColor::SetPalette(int, int*) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x41A6B73: TStyle::SetPalette(int, int*) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x41A96B8: TStyle::Reset(char const*) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x41AA3AD: TStyle::TStyle(char const*, char const*) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x41AAB55: TStyle::BuildStyles() (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x419DCDF: TROOT::TROOT(char const*, char const*, void (**)()) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x419E31D: ROOT::GetROOT() (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x41C7121: TTimer::Reset() (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x41C7350: TTimer::TTimer(long, bool) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x41C7A43: _GLOBAL__I_TTimer.cxx (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730== 
==10730== 
==10730== 2,200 bytes in 10 blocks are possibly lost in loss record 206 of 263
==10730==    at 0x40277EE: operator new(unsigned) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10730==    by 0x41A092A: TStorage::ObjectAlloc(unsigned) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x423ABC4: TObject::operator new(unsigned) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x4345AAC: ROOT::TQObjectInitBehavior::CreateClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, void (*)(void*, TMemberInspector&, char*), char const*, char const*, int, int) const (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x42117B2: ROOT::TGenericClassInfo::GetClass() (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x4335305: TApplication::Dictionary() (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x419C1F8: TROOT::LoadClass(char const*) const (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x4205730: TClass::GetClass(char const*, bool, bool) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x41F9949: TBaseClass::GetClassPointer(bool) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x4191749: TQObject::CollectClassSignalLists(TList&, TClass*) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x41921BF: TQObject::Emit(char const*, long) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x414FBF0: TApplication::KeyPressed(int) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730== 
==10730== 
==10730== 2,505 bytes in 100 blocks are possibly lost in loss record 210 of 263
==10730==    at 0x40277EE: operator new(unsigned) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10730==    by 0x51162E3: std::string::_Rep::_S_create(unsigned, unsigned, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.10)
==10730==    by 0x5116F44: (within /usr/lib/libstdc++.so.6.0.10)
==10730==    by 0x51170B5: std::string::string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.10)
==10730==    by 0x4203448: TClass::AddClass(TClass*) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x4204324: TClass::Init(char const*, short, std::type_info const*, TVirtualIsAProxy*, void (*)(void*, TMemberInspector&, char*), char const*, char const*, int, int, bool) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x4204E0B: TClass::TClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, void (*)(void*, TMemberInspector&, char*), char const*, char const*, int, int, bool) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x4204F7D: ROOT::CreateClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, void (*)(void*, TMemberInspector&, char*), char const*, char const*, int, int) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x4212735: ROOT::TDefaultInitBehavior::CreateClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, void (*)(void*, TMemberInspector&, char*), char const*, char const*, int, int) const (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x42117B2: ROOT::TGenericClassInfo::GetClass() (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x433C2B5: TAttFill::Dictionary() (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x419C1F8: TROOT::LoadClass(char const*) const (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730== 
==10730== 
==10730== 5,328 bytes in 57 blocks are possibly lost in loss record 218 of 263
==10730==    at 0x402710E: operator new[](unsigned) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10730==    by 0x6C34359: TStreamerInfo::Compile() (in /home/rabbitus/ROOT/root/lib/libRIO.so)
==10730==    by 0x6C365F5: TStreamerInfo::BuildOld() (in /home/rabbitus/ROOT/root/lib/libRIO.so)
==10730==    by 0x41FB052: TClass::GetStreamerInfo(int) const (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x952ED2D: TBranchElement::InitInfo() (in /home/rabbitus/ROOT/root/lib/libTree.so)
==10730==    by 0x9525DD7: TBranchElement::GetInfo() const (in /home/rabbitus/ROOT/root/lib/libTree.so)
==10730==    by 0x956B599: TTree::CheckBranchAddressType(TBranch*, TClass*, EDataType, bool) (in /home/rabbitus/ROOT/root/lib/libTree.so)
==10730==    by 0x9568D9B: TTree::SetBranchAddress(char const*, void*, TBranch**, TClass*, EDataType, bool) (in /home/rabbitus/ROOT/root/lib/libTree.so)
==10730==    by 0x90610ED: void TTree::SetBranchAddress<XGCCell>(char const*, XGCCell**, TBranch**) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10730==    by 0x908F96D: XGCProcesSet::AdjustBackground(int, TTree**, int&, TTree**) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10730==    by 0x9090EE6: XGCProcesSet::Preprocess(char const*) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10730==    by 0x907F8AE: XPreProcessManager::Preprocess(char const*, char const*) (in /home/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so)
==10730== 
==10730== 
==10730== 20,458 bytes in 10 blocks are definitely lost in loss record 240 of 263
==10730==    at 0x4027DDE: malloc (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10730==    by 0x48DB77D: G__store_dictposition (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x4852AAA: G__register_sharedlib (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x48E2C06: G__RegisterLibrary (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x484DFC6: G__call_setup_funcs (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x484E211: G__main (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x485046F: G__init_cint (in /home/rabbitus/ROOT/root/lib/libCint.so)
==10730==    by 0x422CAA6: TCint::ResetAll() (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x422CC44: TCint::TCint(char const*, char const*) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x419CC63: TROOT::TROOT(char const*, char const*, void (**)()) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x419E31D: ROOT::GetROOT() (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x41C7121: TTimer::Reset() (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730== 
==10730== 
==10730== 442,489 bytes in 10,646 blocks are possibly lost in loss record 260 of 263
==10730==    at 0x402710E: operator new[](unsigned) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10730==    by 0x41A1AEA: TStringRef::GetRep(int, int) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x41A3A54: TString::TString(char const*) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x41E3ED6: TClassTable::Add(char const*, short, std::type_info const&, void (*)(), int) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x41E3F99: ROOT::AddClass(char const*, short, std::type_info const&, void (*)(), int) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x42127A9: ROOT::TDefaultInitBehavior::Register(char const*, short, std::type_info const&, void (*)(), int) const (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x4210C49: ROOT::TGenericClassInfo::Init(int) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x4211C56: ROOT::TGenericClassInfo::TGenericClassInfo(char const*, int, char const*, int, std::type_info const&, ROOT::TInitBehavior const*, void (*)(), TVirtualIsAProxy*, int, int) (in /home/rabbitus/ROOT/root/lib/libCore.so)
==10730==    by 0x505C3F9: _ZN4ROOTL25GenerateInitInstanceLocalEPK5TRint (in /home/rabbitus/ROOT/root/lib/libRint.so)
==10730==    by 0x505C50C: __static_initialization_and_destruction_0(int, int) (in /home/rabbitus/ROOT/root/lib/libRint.so)
==10730==    by 0x505C576: _GLOBAL__I_G__Rint.cxx (in /home/rabbitus/ROOT/root/lib/libRint.so)
==10730==    by 0x505D39C: (within /home/rabbitus/ROOT/root/lib/libRint.so)
==10730== 
==10730== LEAK SUMMARY:
==10730==    definitely lost: 20,788 bytes in 15 blocks.
==10730==    indirectly lost: 33 bytes in 4 blocks.
==10730==      possibly lost: 452,522 bytes in 10,813 blocks.
==10730==    still reachable: 6,343,863 bytes in 89,602 blocks.
==10730==         suppressed: 0 bytes in 0 blocks.
==10730== Reachable blocks (those to which a pointer was found) are not shown.
==10730== To see them, rerun with: --leak-check=full --show-reachable=yes

Do you think that there is still a memory leak, or can I ignore these messages?

Best regards
Christian

Hi Christian,

All those are expected and are not leaks (but globally initialized memory that are intentionally not deleted at the end of the process).

Cheers,
Philippe.

use the valgrind suppresion file that you can find at $ROOTSYS/etc/valgrind-root.supp

Rene

Dear Philippe

Thank you for this confirmation, thus I could hope that the problem is solved.

Sadly, even when running my program from within ROOT, a user still reports the following crash:

glibc detected *** /usr/local/root-v5.22.00/bin/root.exe: free(): invalid next size (fast): 0x0a4f6c38 ***
======= Backtrace: =========
/lib/libc.so.6[0x466d06]
/lib/libc.so.6(cfree+0x90)[0x46a1e0]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x6006571]
/usr/lib/libstdc++.so.6(_ZdaPv+0x1d)[0x60065cd]
/home/testuser/local/lib/R/library/xps/libs/xps.so(_ZN14XTukeyBiweight9CalculateERdS0_Ri+0x23e)[0x63d71be]
/home/testuser/local/lib/R/library/xps/libs/xps.so(_ZN12XGCProcesSet9DoExpressEiPP5TTreeiS2_+0x10e4)[0x63f6d54]
/home/testuser/local/lib/R/library/xps/libs/xps.so(_ZN12XGCProcesSet7ExpressEiPP5TTreeRiS2_+0x9b)[0x63e7beb]
/home/testuser/local/lib/R/library/xps/libs/xps.so(_ZN12XGCProcesSet10PreprocessEPKc+0xa81)[0x63e9731]
/home/testuser/local/lib/R/library/xps/libs/xps.so(_ZN18XPreProcessManager10PreprocessEPKcS1_+0x5aa)[0x63e60ba]
/home/testuser/local/lib/R/library/xps/libs/xps.so[0x656ab37]
/usr/local/root-v5.22.00/lib/libCint.so(_ZN4Cint19G__ExceptionWrapperEPFiP8G__valuePKcP8G__paramiES1_PcS5_i+0x6a)[0xf5213a]
/usr/local/root-v5.22.00/lib/libCint.so(G__execute_call+0x56)[0x1009746]
/usr/local/root-v5.22.00/lib/libCint.so(G__call_cppfunc+0x260)[0x100a850]
/usr/local/root-v5.22.00/lib/libCint.so(G__interpret_func+0x13b7)[0xfde917]
/usr/local/root-v5.22.00/lib/libCint.so(G__getfunction+0x23b4)[0xfcd714]
/usr/local/root-v5.22.00/lib/libCint.so(G__getstructmem+0x5fc)[0x10c4f5c]
/usr/local/root-v5.22.00/lib/libCint.so(G__getvariable+0x7f0)[0x10bafd0]
/usr/local/root-v5.22.00/lib/libCint.so(G__getitem+0x91)[0xfa0f21]
/usr/local/root-v5.22.00/lib/libCint.so(G__getexpr+0x5be0)[0xfa8250]
/usr/local/root-v5.22.00/lib/libCint.so(G__exec_statement+0xc05e)[0x103d1ce]
/usr/local/root-v5.22.00/lib/libCint.so(G__interpret_func+0x33f6)[0xfe0956]
/usr/local/root-v5.22.00/lib/libCint.so(G__getfunction+0x2417)[0xfcd777]
/usr/local/root-v5.22.00/lib/libCint.so(G__getitem+0x181)[0xfa1011]
/usr/local/root-v5.22.00/lib/libCint.so(G__getexpr+0x5be0)[0xfa8250]
/usr/local/root-v5.22.00/lib/libCint.so(G__exec_statement+0xc05e)[0x103d1ce]
/usr/local/root-v5.22.00/lib/libCint.so[0xf8c1ce]
/usr/local/root-v5.22.00/lib/libCint.so(G__exec_tempfile_fp+0x16)[0xf8c4e6]
/usr/local/root-v5.22.00/lib/libCint.so(G__process_cmd+0x1114)[0x10430d4]
/usr/local/root-v5.22.00/lib/libCore.so(_ZN5TCint11ProcessLineEPKcPN12TInterpreter10EErrorCodeE+0x325)[0x9d1ff5]
/usr/local/root-v5.22.00/lib/libCore.so(_ZN12TApplication11ProcessLineEPKcbPi+0x7d9)[0x8f8899]
/usr/local/root-v5.22.00/lib/libRint.so(_ZN5TRint15HandleTermInputEv+0x1e4)[0x11c7f4]
/usr/local/root-v5.22.00/lib/libRint.so(_ZN17TTermInputHandler6NotifyEv+0x25)[0x11ab95]
/usr/local/root-v5.22.00/lib/libRint.so(_ZN17TTermInputHandler10ReadNotifyEv+0x14)[0x11d2c4]
/usr/local/root-v5.22.00/lib/libCore.so(_ZN11TUnixSystem16CheckDescriptorsEv+0x14b)[0x9e33fb]
/usr/local/root-v5.22.00/lib/libCore.so(_ZN11TUnixSystem16DispatchOneEventEb+0xce)[0x9e39be]
/usr/local/root-v5.22.00/lib/libCore.so(_ZN7TSystem9InnerLoopEv+0x21)[0x954a51]
/usr/local/root-v5.22.00/lib/libCore.so(_ZN7TSystem3RunEv+0x71)[0x958551]
/usr/local/root-v5.22.00/lib/libCore.so(_ZN12TApplication3RunEb+0x38)[0x8f7068]
/usr/local/root-v5.22.00/lib/libRint.so(_ZN5TRint3RunEb+0x38f)[0x11cdbf]
/usr/local/root-v5.22.00/bin/root.exe(main+0x83)[0x8048d83]
/lib/libc.so.6(__libc_start_main+0xdc)[0x413dec]
/usr/local/root-v5.22.00/bin/root.exe(__gxx_personality_v0+0x65)[0x8048be1]
======= Memory map: ========
00110000-00138000 r-xp 00000000 08:13 1145274    /usr/local/root-v5.22.00/lib/libRint.so
00138000-00139000 rwxp 00028000 08:13 1145274    /usr/local/root-v5.22.00/lib/libRint.so
00139000-0013a000 rwxp 00139000 00:00 0
0013a000-0013c000 r-xp 00000000 08:13 3068178    /lib/libdl-2.5.so
0013c000-0013d000 r-xp 00001000 08:13 3068178    /lib/libdl-2.5.so
0013d000-0013e000 rwxp 00002000 08:13 3068178    /lib/libdl-2.5.so
0013e000-00163000 r-xp 00000000 08:13 3068191    /lib/libm-2.5.so
00163000-00164000 r-xp 00024000 08:13 3068191    /lib/libm-2.5.so
00164000-00165000 rwxp 00025000 08:13 3068191    /lib/libm-2.5.so
00165000-00178000 r-xp 00000000 08:13 3068184    /lib/libpthread-2.5.so
00178000-00179000 r-xp 00012000 08:13 3068184    /lib/libpthread-2.5.so
00179000-0017a000 rwxp 00013000 08:13 3068184    /lib/libpthread-2.5.so
0017a000-0017c000 rwxp 0017a000 00:00 0
0017c000-001c1000 r-xp 00000000 08:13 1145273    /usr/local/root-v5.22.00/lib/libPostscript.so
001c1000-001c3000 rwxp 00045000 08:13 1145273    /usr/local/root-v5.22.00/lib/libPostscript.so
001c3000-00208000 r-xp 00000000 08:13 1145207    /usr/local/root-v5.22.00/lib/libThread.so
00208000-0020b000 rwxp 00045000 08:13 1145207    /usr/local/root-v5.22.00/lib/libThread.so
00230000-0024a000 r-xp 00000000 08:13 3068162    /lib/ld-2.5.so
0024a000-0024b000 r-xp 00019000 08:13 3068162    /lib/ld-2.5.so
0024b000-0024c000 rwxp 0001a000 08:13 3068162    /lib/ld-2.5.so
0024c000-003f5000 r-xp 00000000 08:13 1145205    /usr/local/root-v5.22.00/lib/libMathCore.so
003f5000-003fc000 rwxp 001a9000 08:13 1145205    /usr/local/root-v5.22.00/lib/libMathCore.so
003fc000-003fe000 rwxp 003fc000 00:00 0
003fe000-0053b000 r-xp 00000000 08:13 3068177    /lib/libc-2.5.so
0053b000-0053d000 r-xp 0013d000 08:13 3068177    /lib/libc-2.5.so
0053d000-0053e000 rwxp 0013f000 08:13 3068177    /lib/libc-2.5.so
0053e000-00541000 rwxp 0053e000 00:00 0
00541000-006c4000 r-xp 00000000 08:13 1145204    /usr/local/root-v5.22.00/lib/libRIO.so
006c4000-006c8000 rwxp 00183000 08:13 1145204    /usr/local/root-v5.22.00/lib/libRIO.so
006c8000-006c9000 rwxp 006c8000 00:00 0
006ce000-006cf000 r-xp 006ce000 00:00 0          [vdso]
006d0000-006d9000 r-xp 00000000 08:13 3068200    /lib/libnss_files-2.5.so
006d9000-006da000 r-xp 00008000 08:13 3068200    /lib/libnss_files-2.5.so
006da000-006db000 rwxp 00009000 08:13 3068200    /lib/libnss_files-2.5.so
006e3000-00700000 r-xp 00000000 08:13 1145148    /usr/local/root-v5.22.00/lib/libvectorDict.so
00700000-00702000 rwxp 0001c000 08:13 1145148    /usr/local/root-v5.22.00/lib/libvectorDict.so
00702000-007c3000 r-xp 00000000 08:13 1145252    /usr/local/root-v5.22.00/lib/libGpad.so
007c3000-007c8000 rwxp 000c0000 08:13 1145252    /usr/local/root-v5.22.00/lib/libGpad.so
007c8000-007ca000 rwxp 007c8000 00:00 0
007e7000-00e79000 r-xp 00000000 08:13 1145145    /usr/local/root-v5.22.00/lib/libCore.so
00e79000-00e96000 rwxp 00691000 08:13 1145145    /usr/local/root-v5.22.00/lib/libCore.so
00e96000-00f0e000 rwxp 00e96000 00:00 0
00f0e000-01160000 r-xp 00000000 08:13 1144850    /usr/local/root-v5.22.00/lib/libCint.so
01160000-01165000 rwxp 00251000 08:13 1144850    /usr/local/root-v5.22.00/lib/libCint.so
01165000-0162f000 rwxp 01165000 00:00 0
0162f000-019de000 r-xp 00000000 08:13 1145210    /usr/local/root-v5.22.00/lib/libHist.so
019de000-019f0000 rwxp 003af000 08:13 1145210    /usr/local/root-v5.22.00/lib/libHist.so
019f0000-019f3000 rwxp 019f0000 00:00 0
019f3000-02050000 r-xp 00000000 08:13 1145254    /usr/local/root-v5.22.00/lib/libGui.so
02050000-0207f000 rwxp 0065c000 08:13 1145254    /usr/local/root-v5.22.00/lib/libGui.so
0207f000-02088000 rwxp 0207f000 00:00 0
02088000-02182000 r-xp 00000000 08:13 1145253    /usr/local/root-v5.22.00/lib/libGraf3d.so
02182000-02188000 rwxp 000fa000 08:13 1145253    /usr/local/root-v5.22.00/lib/libGraf3d.so
02188000-0218b000 rwxp 02188000 00:00 0
0218b000-02345000 r-xp 00000000 08:13 1145257    /usr/local/root-v5.22.00/lib/libTreePlayer.so
02345000-0234c000 rwxp 001ba000 08:13 1145257    /usr/local/root-v5.22.00/lib/libTreePlayer.so
0234c000-0234f000 rwxp 0234c000 00:00 0
0282b000-028b4000 r-xp 00000000 08:13 1145260    /usr/local/root-v5.22.00/lib/libPhysics.so
028b4000-028b7000 rwxp 00089000 08:13 1145260    /usr/local/root-v5.22.00/lib/libPhysics.so
02bbe000-02c82000 r-xp 00000000 08:13 1145259    /usr/local/root-v5.22.00/lib/libTreeViewer.so
02c82000-02c87000 rwxp 000c4000 08:13 1145259    /usr/local/root-v5.22.00/lib/libTreeViewer.so
02f42000-0303f000 r-xp 00000000 08:13 1145206    /usr/local/root-v5.22.00/lib/libNet.so
0303f000-03046000 rwxp 000fd000 08:13 1145206    /usr/local/root-v5.22.00/lib/libNet.so
03046000-03047000 rwxp 03046000 00:00 0
037a3000-0392c000 r-xp 00000000 08:13 1145258    /usr/local/root-v5.22.00/lib/libGed.so
0392c000-03936000 rwxp 00189000 08:13 1145258    /usr/local/root-v5.22.00/lib/libGed.so
03936000-03937000 rwxp 03936000 00:00 0
03b72000-03d3b000 r-xp 00000000 08:13 1145211    /usr/local/root-v5.22.00/lib/libTree.so
03d3b000-03d44000 rwxp 001c9000 08:13 1145211    /usr/local/root-v5.22.00/lib/libTree.so
03d44000-03d47000 rwxp 03d44000 00:00 0
045a2000-047d7000 r-xp 00000000 08:13 1145208    /usr/local/root-v5.22.00/lib/libMatrix.so
047d7000-047de000 rwxp 00235000 08:13 1145208    /usr/local/root-v5.22.00/lib/libMatrix.so
047de000-047e0000 rwxp 047de000 00:00 0
05f45000-05f50000 r-xp 00000000 08:13 3068237    /lib/libgcc_s-4.1.2-20080825.so.1
05f50000-05f51000 rwxp 0000a000 08:13 3068237    /lib/libgcc_s-4.1.2-20080825.so.1
05f53000-06033000 r-xp 00000000 08:13 75850      /usr/lib/libstdc++.so.6.0.8
06033000-06037000 r-xp 000df000 08:13 75850      /usr/lib/libstdc++.so.6.0.8
06037000-06038000 rwxp 000e3000 08:13 75850      /usr/lib/libstdc++.so.6.0.8
06038000-0603e000 rwxp 06038000 00:00 0
062a5000-066fa000 r-xp 00000000 08:11 1376266    /home/testuser/local/lib/R/library/xps/libs/xps.so
066fa000-0670f000 rwxp 00455000 08:11 1376266    /home/testuser/local/lib/R/library/xps/libs/xps.so
0670f000-06717000 rwxp 0670f000 00:00 0
07499000-07663000 r-xp 00000000 08:13 1145213    /usr/local/root-v5.22.00/lib/libGraf.so
07663000-0766e000 rwxp 001ca000 08:13 1145213    /usr/local/root-v5.22.00/lib/libGraf.so
0766e000-07676000 rwxp 0766e000 00:00 0
0796c000-07975000 r-xp 00000000 08:13 3068229    /lib/libcrypt-2.5.so
07975000-07976000 r-xp 00008000 08:13 3068229    /lib/libcrypt-2.5.so
07976000-07977000 rwxp 00009000 08:13 3068229    /lib/libcrypt-2.5.so
07977000-0799e000 rwxp 07977000 00:00 0
079bf000-07b44000 r-xp 00000000 08:13 1082386    /usr/local/root-v5.22.00/cint/cint/stl/vector.dll
07b44000-07b48000 rwxp 00184000 08:13 1082386    /usr/local/root-v5.22.00/cint/cint/stl/vector.dll
08048000-0804a000 r-xp 00000000 08:13 3264014    /usr/local/root-v5.22.00/bin/root.exe
0804a000-0804b000 rw-p 00001000 08:13 3264014    /usr/local/root-v5.22.00/bin/root.exe
09b68000-0a641000 rw-p 09b68000 00:00 0
a8200000-a8221000 rw-p a8200000 00:00 0
a8221000-a8300000 ---p a8221000 00:00 0
a833c000-b7fd4000 rw-p a833c000 00:00 0
b7fd4000-b7fe4000 rw-p b7fd4000 00:00 0
bff1c000-bff69000 rw-p bff1c000 00:00 0          [stack]

Do you have any idea what might couse the crash?

The program seems to crash in the following function:

Int_t XTukeyBiweight::Calculate(Double_t &value1, Double_t &value2, Int_t &num)
{
// Test number of parameters
   if (TestNumParameters(6) != errNoErr) return errInitParameters;

// Parameters
   Double_t ctau   = fPars[0];  //contrast tau
   Double_t stau   = fPars[1];  //scale tau
   Double_t delta  = fPars[2];  //delta
   Double_t c      = fPars[3];  //c for tukey biweight
   Double_t eps    = fPars[4];  //epsilon for tukey biweight
   Double_t neglog = fPars[5];  //value used if value is negative
   Double_t var    = 0.0;

// Tukey biweight
   Double_t sb = TStat::TukeyBiweight(fLength, fArray, var, c, eps);

   Double_t *ct = 0;
   if (!(ct = new (nothrow) Double_t[fLength])) return errInitMemory;

// Compute contrast value and subtract from PM
   for (Int_t i=0; i<fLength; i++) {
      ct[i] = fInten2[i];

      if (fInten2[i] >= fInten1[i]) {
         if (sb > ctau) {
            ct[i] = fInten1[i] / TMath::Power(2, sb);
         } else if (sb <= ctau) {
            ct[i] = fInten1[i] / TMath::Power(2, ctau/(1 + (ctau - sb)/stau));
         }//if
      }//if

      fArray[i] = TMath::Max((fInten1[i] - ct[i]), delta); 
   }//for_i

// Compute expression value and variance
   fArray = Array2Log(fLength, fArray, neglog, fLogBase);
   ct[0]  = TStat::TukeyBiweight(fLength, fArray, ct[1], c, eps);
   ct     = Array2Pow(2, ct, fLogBase);

// Return values
   value1 = ct[0];
   value2 = ct[1];
   num    = fLength;

   if (ct) {delete [] ct; ct = 0;}

   return errNoErr;
}//Calculate

which calls the following function:

Double_t TStat::TukeyBiweight(Int_t n, const Double_t *x, Double_t &var, Double_t c, Double_t eps)
{
   // Calculate one-step Tukey Biweight for array x of length n
   // c is a tuning constant and eps is a small value to prevent zero division
   // Variable var will return the square of S(bi), i.e. of the measure of
   // uncertainty of the biweight. The t-distribution can be used to determine
   // the confidence interval: T(bi) +/- t*sqrt(var/n)

   if (n == 1) return x[0];

   Double_t m, s, cseps, uu2;
   Double_t sumwx = 0.0;
   Double_t sumw  = 0.0;
   Double_t tb    = 0.0;

// Init local arrays
   Double_t *u = 0;
   Double_t *w = 0;
   if (!(u = new (nothrow) Double_t[n])) goto cleanup;
   if (!(w = new (nothrow) Double_t[n])) goto cleanup;
   for (Int_t i=0; i<n; i++) u[i] = w[i] = 0.0;

   m = TStat::Median(n, x);
   for (Int_t i=0; i<n; i++) {
      u[i] = TMath::Abs(x[i] - m);
   }//for_i
   s = TStat::Median(n, u);

// Calculate one-step tukey biweight
   sumwx = 0.0;
   sumw  = 0.0;
   cseps = c*s + eps;
   for (Int_t i=0; i<n; i++) {
      u[i] = (x[i] - m) / cseps;
      uu2  = 1 - u[i]*u[i];
      w[i] = (TMath::Abs(u[i]) <= 1.0) ? uu2*uu2 : 0.0;
      sumwx += w[i]*x[i];
      sumw  += w[i];
   }//for_i
   tb = sumwx / sumw;

// Calculate variance for tukey biweight
   sumwx = 0.0;
   sumw  = 0.0;
   for (Int_t i=0; i<n; i++) {
      uu2  = (x[i] - tb)*w[i];
      sumwx += uu2*uu2;
      sumw  += TMath::Sqrt(w[i])*(1 - 5*u[i]*u[i]);
   }//for_i
   sumw = TMath::Abs(sumw);
   var = n*sumwx / (sumw*sumw);

// Cleanup
cleanup:
   if (w) {delete [] w; w = 0;}
   if (u) {delete [] u; u = 0;}

   return tb;
}//TukeyBiweight

Do you see any problems in these functions which may cause the crash?
(The user uses CentOS release 5.2 and compiled root:5.22/00 from source)

Best regards
Christian

Hi Christian,

Unfortunately I do not see anything obviously wrong :frowning:.

Cheers,
Philippe.

To try to debug this I would add printing of the address just after the new and just before the delete. I would also check that the size is the one expected (fLength,n).

This ct = Array2Pow(2, ct, fLogBase); looks suspicious to me - probably until I know what Array2Pow looks like :slight_smile:

Cheers, Axel.

Dear Axel,

Maybe, you are right, this is the function:

Double_t *XHybridizer::Array2Pow(Int_t n, Double_t *x, const char *base)
{
   // Convert array x from logarithm of base and return converted  x

   if (n == 0 || x == 0) return 0;

   if (strcmp(base, "0") == 0) {
      return x;
   } else if (strcmp(base, "log2") == 0) {
      for (Int_t i=0; i<n; i++) { 
         x[i] = TMath::Power(2, x[i]);
      }//for_i
   } else if (strcmp(base, "log10") == 0) {
      for (Int_t i=0; i<n; i++) { 
         x[i] = TMath::Power(10, x[i]);
      }//for_i
   } else if (strcmp(base, "log") == 0) {
      for (Int_t i=0; i<n; i++) { 
         x[i] = TMath::Power(TMath::E(), x[i]);
      }//for_i
   }//if

   return x;
}//Array2Pow

Thus, I convert only the first two values of array ct, and store it in the array.
Does this result in a memory leak (not detected by valgrind)?

Best regards
Christian

Hi,

Are you guaranteed that fLength is always greater then 2?

Cheers,
Philippe.

Dear Philippe

Yes…!!!
At least this was the case for the chips for which the algorithm was designed. However, after receiving your mail I
realized that this is no longer true for the new chips, thus this stupid mistake seems to be the reason for the crash.
Luckily, it is easy to solve, I simply do:

ct = new (nothrow) Double_t[fLength + 1];

Thank you and Axel for your help; thanks also to Rene for his tip to use valgrind-root.supp.
I hope that this did finally solve my problem.

Best regards
Christian