Hi,
I have a code for producing a tree and adding branches which runs without any problem on 5.16; nevertheless, with 5.18 or 5.20 segmentation fault happens when trying to add branch. I have been looking into this but I could no find the problem; last chance, I post…sorry!
I hope parts of the code are enough to identify the problem, that happens when a branch is added through the method AddEntry.
main:
(…)
GAWPrimaryParticle *pGAWPrimaryParticle = new GAWPrimaryParticle();
GAWeventHeader *pGAWeventHeader = new GAWeventHeader();
GAWTree *gawt = new GAWTree(“a.root”,“W”);
gawt->AddEntry(pGAWPrimaryParticle);
(…)
GAWTree class:
(…)
GAWTree::GAWTree(string Filename, string option)
{
if (option==“W”) {
RootFile = new TFile(Filename.c_str(),“RECREATE”);
} else if (option==“R”) {
RootFile = new TFile(Filename.c_str());
}
pTree = new TTree(“GAWTree”,“GAW event tree”);
pTree->SetAutoSave(100000000);
bufsize = 32000;
split = 2;
if (split) bufsize/=4;
branchstyle =1;
TTree::SetBranchStyle(branchstyle);
}
void GAWTree::AddEntry(GAWPrimaryParticle *&pGAW)
{
TBranch *branch = pTree->Branch(“GAWPrimaryParticle”,“GAWPrimaryParticle”,&pGAW, bufsize, split);
branch->SetAutoDelete(kFALSE);
}
(…)
Thanks for any suggestion,
Fernando Barao.
ps: the full main and class code are in the attached tar.
rootforum.tar (20 KB)