Problem filling cloned TTree


The problem I am facing, in pseudo-code is as follows:

class MyClass {
fun ();
TChain* thisChain;
TTree* myTree;

MyClass::init () {
// Initialise thisChain;
myTree = thisChain->CloneTree(0);

MyClass::fun () {

for (…) { // Loop over thisChain
if (…) myTree->Fill(); // Fill Cloned tree after applying some selection criteria


This crashes while trying to fill the cloned tree, with the stack trace [1]. It is definitely a memory allocation problem but I’m not sure what the workaround could be.


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.

#5 0x0000003d8107c60c in memcpy () from /lib64/
#6 0x00002b852af79dd9 in TBufferFile::WriteFastArray(char const*, int) ()
from /afs/
#7 0x00002b85280cf5dc in TBranch::FillLeaves(TBuffer&) ()
from /afs/
#8 0x00002b85280d1b1c in TBranch::Fill() ()
from /afs/
#9 0x00002b8528116d2b in TTree::Fill() ()
from /afs/
#10 0x000000000040c566 in myAnalyzer::evtLoop_() ()
#11 0x0000000000407464 in myAnalyzer::process_() ()
#12 0x0000000000404f34 in main ()


myTree = thisChain->CloneTree(0);[/quote]The output/cloned TTree is likely to be attached to the input file (and thus deleted when one of the input file is closed). Make sure to explicitly attached it to your output file:myTree->SetDirectory(fOutputFile);