Root Crash deleting a RooDataSet

Dear all.
I have a puzzling problem. I’m submitting roofit jobs on the grid (ganga + Dirac). Since I need to
generate/fit a lot of events with a complicated PDF I end up [if making a one shot generation] with a
VERY large (>5Gb) memory use that makes my job crash. So I have tried to make ‘several’ small dataset
generations, adding them up in my ‘big’ dataset.

Each time I add the new dataset to the big one and then I delete it regenrating a new one. This
nicely works on my laptop/lxplus interactive session: the memory usage now is well under control
<1Gb and the final dataset can be used for the studies.
But when I try to ship this job to the grid I get a segmentation fault in the loop of dataset
generation [that i repeat does not happen on my laptop/lxplus].
The problem is that the loop foresee 43 steps [adding 43 datasets of 10k events each] and the crash
appears at random values of the loop index: sometimes the job crashes at the 10th step, sometimes at
15 or 12 or 23 , etc etc. and NEVER reaches the end of events generation.

The trace is appended at the bottom.
The incriminated code lines are appended below as well.

Any help in trying to understand this behaviour will be much much appreciated.

Cheers,
alessio

##########
code
##########
//data_set is the dataset used for the final fit
if(f_nEvt < 10000) {
//Small dataset: perform one shot generation
data_set = pdf_FitPdf->generate(*pdf_obs,f_nEvt);
} else {
cout<<“DEBUG:: High number of events to be generated: “<<f_nEvt<<endl;
int ndata = f_nEvt/10000;
//Make several small generation of 10k events each
string dn = “myd”; char dname[200];
int genEv(0);
for(int id = 0; id<ndata; id++) {
sprintf(dname,”%s%d”,“RooData_”,id);
RooDataSet *myd = new RooDataSet(dname,dname,*pdf_obs);
dn += “a”;
if(id == 0) {
cout<<"DEBUG:: Generating data_set "<<id<<endl;
myd = pdf_FitPdf->generate(*pdf_obs,10000);
genEv += 10000;
}
//Appending
if(id) data_set->append(*myd);
cout<<“DEBUG:: Appended”<<endl;
delete myd;
}
int LastEv = f_nEvt - genEv;
RooDataSet *myd = new RooDataSet();
myd = pdf_FitPdf->generate(*pdf_obs,LastEv);
data_set->append(*myd);
delete myd;
}

##########
trace
##########

std.err
*** Break *** segmentation violation
Function MacroCode() busy flag cleared
*** glibc detected *** double free or corruption (!prev): 0x0000000007e57a20 ***

std.out
(no debugging symbols found)
Using host libthread_db library “/lib64/tls/libthread_db.so.1”.
Attaching to program: /proc/7362/exe, process 7362
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
[Thread debugging using libthread_db enabled]
[New Thread 182914399552 (LWP 7362)]
(no debugging symbols found)…done.
0x0000003806d8f504 in waitpid ()
from /lib64/tls/libc.so.6
#1 0x0000003806d39a1f in do_system () from /lib64/tls/libc.so.6
#2 0x0000002a9579f88d in TUnixSystem::StackTrace ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCore.so
#3 0x0000002a9579c60a in TUnixSystem::DispatchSignals ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCore.so
#4
#5 0x0000002a9a4fa482 in RooHashTable::~RooHashTable$delete ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libRooFitCore.so
#6 0x0000002a9a504f49 in RooLinkedList::Delete ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libRooFitCore.so
#7 0x0000002a9a4793ec in RooAbsCollection::~RooAbsCollection$base ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libRooFitCore.so
#8 0x0000002a9a4b0d31 in RooArgSet::~RooArgSet$delete ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libRooFitCore.so
#9 0x0000002a9a504ed9 in RooLinkedList::Delete ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libRooFitCore.so
#10 0x0000002a9a533c8f in RooProdPdf::~RooProdPdf$delete ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libRooFitCore.so
#11 0x0000002a9a4791a9 in RooAbsCollection::safeDeleteList ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libRooFitCore.so
#12 0x0000002a9a4793ec in RooAbsCollection::~RooAbsCollection$base ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libRooFitCore.so
#13 0x0000002a9a4b0d31 in RooArgSet::~RooArgSet$delete ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libRooFitCore.so
#14 0x0000002a9a4a224e in RooAddGenContext::~RooAddGenContext$delete ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libRooFitCore.so
#15 0x0000002a9a485ba1 in RooAbsPdf::generate ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libRooFitCore.so
#16 0x0000002a99936b94 in FitCodeTool::getEvents (this=0x1198730,
SupSeed=1090998) at FitCodeTool.cc:1529
#17 0x0000002a9993d7f7 in G__FitCodeToolDict_850_0_75 (result7=0x7fbffc7a10,
funcname=0x1197790 “\001”, libp=0x7fbffc1800, hash=0)
at FitCodeToolDict.cc:640
#18 0x0000002a95f21315 in G__call_cppfunc ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#19 0x0000002a95f082be in G__interpret_func ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#20 0x0000002a95ef67c2 in G__getfunction ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#21 0x0000002a95fb4f64 in G__getstructmem ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#22 0x0000002a95fad0c2 in G__getvariable ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#23 0x0000002a95ecca11 in G__getitem ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#24 0x0000002a95ed146a in G__getexpr ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#25 0x0000002a95f4db45 in G__exec_statement ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#26 0x0000002a95f09203 in G__interpret_func ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#27 0x0000002a95ef6dc7 in G__getfunction ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#28 0x0000002a95ecd0c7 in G__getitem ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#29 0x0000002a95ed146a in G__getexpr ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#30 0x0000002a95eddbac in G__calc_internal ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#31 0x0000002a95f5bcca in G__process_cmd ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCint.so
#32 0x0000002a9576e2cf in TCint::ProcessLine ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCore.so
#33 0x0000002a956dd296 in TApplication::ExecuteFile ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCore.so
#34 0x0000002a956db622 in TApplication::ProcessLine ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libCore.so
#35 0x0000002a96675762 in TRint::Run ()
from
/pool/1489932.fal-pygrid-18.lancs.ac.uk/WMS_node014_06471_https_3a_2f_2frb123.cern.ch_3a9000_2fA3yKXi
R16HVbsGxIGV3XyA/lib/lcg/external/root/5.18.00a/slc4_amd64_gcc34/root/lib/libRint.so
#36 0x000000000040106d in main ()