TEventList problems

Here are two pieces of code. I would expect that both of them would give the same result, but that is not true.

...
vector< vector< TEventList > > listTree;
...
map< double, vector< TEventList > >::iterator it = selectionLists[j].find( curCutValue[j] );
...
for (unsigned k = 0; k < samples.size(); ++k) {
	listTree[j][k] = listTree[j + 1][k];
	listTree[j][k].Intersect( &(it->second[k]) );
}
for (unsigned k = 0; k < samples.size(); ++k) {
	listTree[j][k] = listTree[j + 1][k];
	TEventList * nn = new TEventList( listTree[j][k] );
	nn->Intersect( &(it->second[k]) );
	listTree[j][k] = *nn;
	delete nn;
}

First piece gives following error, but not first time the loop is executed, but somewhere later

*** glibc detected *** ./HZZ2l2nu: double free or corruption (!prev): 0x0a53ece8 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(+0x6b591)[0x5293591]
/lib/tls/i686/cmov/libc.so.6(+0x6cde8)[0x5294de8]
/lib/tls/i686/cmov/libc.so.6(cfree+0x6d)[0x5297ecd]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x1596741]
/usr/lib/libstdc++.so.6(_ZdaPv+0x1d)[0x159679d]
/home/zablocki/CMS/root/lib/libTree.so(_ZN10TEventList9IntersectEPKS_+0xf2)[0x557a732]
./HZZ2l2nu(_Z11scanAllCutsSt6vectorI6sampleSaIS0_EERKS_IPK3CutSaIS5_EERKS_IPS3_SaISA_EERKS_IP4optCSaISG_EE+0x120a)[0x806161b]
./HZZ2l2nu(main+0x5562)[0x80554af]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0x523ebd6]
./HZZ2l2nu[0x804fde1]
======= Memory map: ========
...

but second one works without any problems. I really don’t understand what’s going on. Can anyone explain that? Is this bug or I’m missing something?

Hi,

CINT has problems tracking the temporaries of the line

Please either compile your code or spell the arguments out by creating variables that store intermediary results (it->second, [k], &).

Cheers, Axel.

Hello,

the problem is that this code was compiled (with g++ as executable).

I don’t fully understand what you mean by saying [quote]spell the arguments out by creating variables that store intermediary results (it->second, [k], &)[/quote]
Isn’t that what I’m doing in the piece of code that is working?

Hi,

I take back all I said :slight_smile:

Can you provide running code that shows the problem? I.e. please fill in the “…” in between the code fragments that you posted, such that I can call the code and see the error.

Cheers, Axel.

The code is pretty long and this just one function of many. Here is gzipped version. To run the code though you would need also specific root-tuples. The problem is in scanAllCuts() function in CreatePlot.cpp.

code.tgz (15.2 KB)

There might be issue with the TEventList operator=. What does valgrind says if you use it to run your failling example?

Cheers,
Philippe.

For this code valgrind gives like 40k errors, where probably all of them come from root libraries. I reported this in other post. This makes almost impossible to find something useful with valgrind.

Hi,

Did you try the ROOT suppression file $ROOTSYS/etc/valgrind-root.supp ?

Philippe.

Yes, the number of errors I quoted was after using suppression file.

[quote]For this code valgrind gives like 40k errors, where probably all of them come from root libraries
Yes, the number of errors I quoted was after using suppression file.[/quote]humm … odd. Can you send us the valgrind log file?

Cheers,
Philippe.