Same proxy for two TChains crashing

Hi,

I am getting a crash when I try to use the same proxy for two different TChains. I want to be able to MakeProxy on both chains individually, but using the same macro file. So this means the proxy tselector needs to be reloaded. Not sure if this reload is causing the crash somehow? I’ve prepared a minimal example which crashes for me in root 5.30…

here’s the proxy macro:

myProxy.C....

Double_t myProxy() {return var*2;}

run the following macro (called it proxyFail.C)

proxyFail.C....

void makeTree() {
  TFile f1("testTree.root","RECREATE");
  TTree* t = new TTree("myTree","myTree");
  TTree* t2 = new TTree("newTree","newTree");

  Double_t var = 0;
  std::vector<double> vec;
  t->Branch("var",&var);
  t->Branch("vec",&vec);
  t2->Branch("var");

  TRandom3 rand;

  for(int i=0;i<2000;i++) {
    var = rand.Uniform();
    vec.resize((i % 5)+1);
    for(int j=0;j<(i%5)+1;j++) {
      vec[j] = rand.Uniform();
    }
    t->Fill();
    t2->Fill();
  }
  t->Write();t2->Write();
  f1.Write();

  f1.Close();
}


TSelector* getSelector(TChain& c) {
  c.MakeProxy("myGenProxy","myProxy.C");
  return TSelector::GetSelector("myGenProxy.h+");
}


void proxyFail() {
  makeTree();
  TChain c("myTree");
  c.Add("testTree.root");
  TSelector *sel = getSelector(c);
  if(sel)
    c.Process(sel);


  TChain d("newTree");
  d.Add("testTree.root");
  TSelector *sel2 = getSelector(d);
  if(sel2)
    d.Process(sel2);
  
}

If I run just the first chain, it all works. The second chain running gives me a crash like this:

Info in : modified script has already been compiled and loaded
Info in : it will be regenerated and reloaded!
Info in TUnixSystem::ACLiC: creating shared library /path/dynamic/./myGenProxy_h.so

*** Break *** segmentation violation

Thanks!

Will

This seems to be a problem with the TChain that is created in scope getting destroyed when the dictionary for the proxy is reloaded. Switching things to the heap seems to have resolved this issue.

Sorry about the noise.