Segfault in rebdsim when using branches from storeCollimatorInfo

Issue #271 resolved
Former user created an issue

Hello, I am experiencing a segfault when trying to run rebdsim on an analysis config with branches which are present when storeCollimatorInfo=1. Interestingly the error does not occur unless there is more than one COLL_ histogram defined, if there is only one then it run without issue. The error is below:

rebdsim> configuration file name : failAnaConfig.txt
Loading> "output.root" : data version 4
Analysis on "Beam." beginning
Analysis on "Beam." complete
Analysis on "Event." beginning

 *** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[/usr/lib/system/libsystem_malloc.dylib] tiny_free_no_lock (no debug info)
[/Users/Stuart/Packages/Physics/root/6-16-00/install/lib/libTree.so] TBranchElement::ReadLeavesMember(TBuffer&) /Users/Stuart/Physics/Packages/root/6-16-00/root-6.16.00/tree/tree/src/TBranchElement.cxx:4415
[/Users/Stuart/Packages/Physics/root/6-16-00/install/lib/libTree.so] TBranch::GetEntry(long long, int) /Users/Stuart/Physics/Packages/root/6-16-00/build/include/TBuffer.h:96
[/Users/Stuart/Packages/Physics/root/6-16-00/install/lib/libTree.so] TBranchElement::GetEntry(long long, int) /Users/Stuart/Physics/Packages/root/6-16-00/root-6.16.00/tree/tree/src/TBranchElement.cxx:2653
[/Users/Stuart/Packages/Physics/root/6-16-00/install/lib/libTree.so] TTree::GetEntry(long long, int) /Users/Stuart/Physics/Packages/root/6-16-00/root-6.16.00/tree/tree/src/TTree.cxx:5414
[/Users/Stuart/Physics/Packages/bdsim/bdsim-install/lib/librebdsim.dylib] EventAnalysis::Process() /Users/Stuart/Physics/Packages/bdsim/bdsim/analysis/EventAnalysis.cc:143
[/Users/Stuart/Physics/Packages/bdsim/bdsim-install/lib/librebdsim.dylib] EventAnalysis::Execute() /Users/Stuart/Physics/Packages/bdsim/bdsim/analysis/EventAnalysis.cc:104
[/Users/Stuart/Physics/bdsim/bdsim-install/bin/rebdsim] main /Users/Stuart/Physics/Packages/bdsim/bdsim/analysis/rebdsim.cc:130
[/usr/lib/system/libdyld.dylib] start (no debug info)
[<unknown binary>] (no debug info)

I have attached an example analysis and output file to show the failure. It includes multiple definitions in the config, so that one can see the effect of uncommenting or commenting the extra COLL_ histogram definitions on the segfaulting.

Comments (1)

  1. Former user Account Deleted reporter

    Fixed in 8c9a4790. The problem was that SetBranchAddress requires a pointer to a pointer. If these pointers are stored in a vector, and the vector is resized (i.e. push_back), then the whole vector will be copied to a new location, and all the stored pointers will be invalidated, as their addresses will have changed, leading to a segfault when trying to access. The solution therefore is to know in advance how many collimator branches to be switched on and resize the vector to the correct length before filling, so that the contents are never copied.

  2. Log in to comment