Segmentation fault when adding branch to tree

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)

Hi,

I do not see anything obviously wrong. What is the stack trace at the time of the segmentation fault? What is the ouput of your code just before the segmentation fault (actually to make sure you actually see the whole output your should change the cout into cerr).

Cheers,
Philippe

Hi,

The key issue was expressed in a warning:Warning in <TClassTable::Add>: class CLHEP::Hep3Vector already in TClassTable This double dictionary for Hep3Vector directly lead to the segmentation fault.

Cheers,
Philippe.