While working with RooDataSets and RooWorkspaces, I need to use a RooTreeDataStore as described in the RooDataSet docs due to the memory limitation of RooVectorDataStore.
I am using python 2.7 (it does not feel good, but that is another story) for the “high level” script and run into Segmentation Violations at the end of the script. As far as I can tell, this happens if I start opening additional TFiles, to e.g. write out a new RooWorkspace that contains a Tree-backed RooDataSet.
I tried to come up with a minimal example:
import ROOT ws = ROOT.RooWorkspace('ws') # workspace to store fit results, etc. x = ROOT.RooRealVar('x', 'x', 0) # generate some data in this dimension later fs = ROOT.TFile('store.root', 'RECREATE') ROOT.RooAbsData.setDefaultStorageType(ROOT.RooAbsData.Tree) # use Tree-backed data store data = ROOT.RooDataSet('data', 'data', ROOT.RooArgSet(x)) for v in range(1000): # fill dataset with very meaningful data x.setVal(v) data.add(ROOT.RooArgSet(x)) getattr(ws, 'import')(data) # add dataset to workspace # `import` is a python keyword, need to use `getattr` ws.Print('v') # check that everything looks as expected wf = ROOT.TFile('ws.root', 'RECREATE') # save workspace to this file ws.Write() wf.Close() # this seems to be part of the problem # when leaving wf opened and deleting `ws` and `data`, there is no segfault # del ws, data print('Done!') # the segfault appears after this line
This is (to my eye) the relevant part of the segfault:
The lines below might hint at the cause of the crash. You may get help by asking at the ROOT forum http://root.cern.ch/forum Only if you are really convinced it is a bug in ROOT then please submit a report at http://root.cern.ch/bugs Please post the ENTIRE stack trace from above as an attachment in addition to anything else that might help us fixing this issue. =========================================================== #9 0x000000000278b530 in ?? () #10 0x00007f658dae32f3 in RooTreeDataStore::~RooTreeDataStore (this=0x27679a0, __in_chrg=<optimized out>) at /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8testing/LABEL/centos7/build/projects/ROOT-6.18.04/src/ROOT/6.18.04/roofit/roofitcore/src/RooTreeDataStore.cxx:380 #11 0x00007f658dae338c in RooTreeDataStore::~RooTreeDataStore (this=0x27679a0, __in_chrg=<optimized out>) at /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8testing/LABEL/centos7/build/projects/ROOT-6.18.04/src/ROOT/6.18.04/roofit/roofitcore/src/RooTreeDataStore.cxx:385 #12 0x00007f658d8f28ef in RooAbsData::~RooAbsData (this=0x38118c0, __in_chrg=<optimized out>) at /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8testing/LABEL/centos7/build/projects/ROOT-6.18.04/src/ROOT/6.18.04/roofit/roofitcore/src/RooAbsData.cxx:261 #13 0x00007f658d9b4eab in RooDataSet::~RooDataSet (this=0x38118c0, __in_chrg=<optimized out>) at /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8testing/LABEL/centos7/build/projects/ROOT-6.18.04/src/ROOT/6.18.04/roofit/roofitcore/src/RooDataSet.cxx:944 #14 0x00007f658d9b4edc in RooDataSet::~RooDataSet (this=0x38118c0, __in_chrg=<optimized out>) at /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8testing/LABEL/centos7/build/projects/ROOT-6.18.04/src/ROOT/6.18.04/roofit/roofitcore/src/RooDataSet.cxx:948 #15 0x00007f658d838a23 in ROOT::delete_RooDataSet (p=0x38118c0) at /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8testing/LABEL/centos7/build/projects/ROOT-6.18.04/src/ROOT-6.18.04-build/roofit/roofitcore/G__RooFitCore.cxx:17319 #16 0x00007f659de82093 in TClass::Destructor (this=0x37733c0, obj=0x38118c0, dtorOnly=false) at /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8testing/LABEL/centos7/build/projects/ROOT-6.18.04/src/ROOT/6.18.04/core/meta/src/TClass.cxx:5215 #17 0x00007f65a008c811 in Cppyy::Destruct (type=33, instance=0x38118c0) at /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8testing/LABEL/centos7/build/projects/ROOT-6.18.04/src/ROOT/6.18.04/bindings/pyroot/src/Cppyy.cxx:291 #18 0x00007f65a00a9353 in PyROOT::op_dealloc_nofree (pyobj=0x7f65a6d58410) at /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8testing/LABEL/centos7/build/projects/ROOT-6.18.04/src/ROOT/6.18.04/bindings/pyroot/src/ObjectProxy.cxx:59 #19 0x00007f65a00a9aa9 in PyROOT::(anonymous namespace)::op_dealloc (pyobj=0x7f65a6d58410) at /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8testing/LABEL/centos7/build/projects/ROOT-6.18.04/src/ROOT/6.18.04/bindings/pyroot/src/ObjectProxy.cxx:212
Deleting the references to
data manually, and don’t closing the file
wf seems to solve the problem partly. At least, the script exits normally. In this case, the Tree store ends up in the
ws.root file as a separate key, though.
I would have hoped that the file
store.root will be used as the RooDataStore, but it seems to be unused at all.
Is there a way to point the RooTreeDataStore to a specific TFile that does not interfere with other opened files? Any help would be very appreciated
ROOT Version: 6.18.04
Platform: linux-64 on Centos7
Compiler: gcc 8