Segmentation violation after CopyTree

Hello,

that bug is said to be fixed but I still seem to experience it. I am using a root version compiled from the source: ROOT 5.34/18 (v5-34-18@v5-34-18, Mar 14 2014, 16:29:50 on linuxx8664gcc). My sytem is Release 12.04 (precise) 64-bit, Kernel Linux 3.2.0-61-generic, GNOME 3.4.2. The code worked with root 5.28.00h

Here the part of the code it crashes:

void
Overlap::AddTreesToFiles(TString inputdir){
  TString ovstr = "_ovcode";
  TString rmstr = "_ovremoved";

  for( int imode = 0; imode < Modes::nModes; imode++ ){
    //open files for modifications
    TString fname = inputdir + Modes::ModeName(imode) + ".root";
    TFile f(fname, "UPDATE");
    if( !f.IsOpen() ){
      cout << "WARNING: file not found skipping it! fname = " << fname << endl;
      continue;
    }

    for(int ipi = 0; ipi < Pions::AllPi; ipi++){
      //debug: skip for now to save time
      //if(  ipi == 0 ){
      //  cout << "skipping npi = 0 " << endl;
      //  continue;
      //}

      TString treename = Modes::ModeName( imode ) + Pions::GetID( ipi ) + "_" + exttree;

      //remove the old overlap trees if present
      if( f.Get( treename + ovstr ) || f.Get( treename + rmstr ) ){
        cout << "WARNING: found old overlap trees in the file for " << treename << endl;
        cout << "will remove those now!" << endl;
        f.Delete( treename + ovstr + ";*");
        f.Delete( treename + rmstr + ";*");
      }


      TTree * t = (TTree*)f.Get( treename );
      if( !t ){
        cout << "WARNING: tree not found: " << treename << " skipping this sample" << endl;
        continue;
      }

      //get the tree with overlap codes
      TTree * ovt = GetOverlapTree( t, treename + ovstr, (Pions::nPi)ipi, (Modes::Mode)imode);
      f.cd();
      ovt->Write();

      t->AddFriend( ovt );

      int rmcode = GetRemCode( (Pions::nPi)ipi, (Modes::Mode)imode );
      TString cut = "0==(ovcode&";
      cut += rmcode;
      cut += ")";

      //==============>This is the line where it crashes:
      TTree * rmt = t->CopyTree(cut);
      rmt->SetName( treename + rmstr );
      f.cd();
      rmt->Write();

    }//end ipi
    f.Close();
  }//end imode 


}
                                                                                                                                                            

I can not provide a small standalone example.

Here the entire stack:

===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007fcf8227ec8e in waitpid () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007fcf8220429e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007fcf831455b7 in TUnixSystem::StackTrace() () from /home/thomas/work/computing/root_5_34_18/lib/libCore.so
#3  0x00007fcf83147ea3 in TUnixSystem::DispatchSignals(ESignals) () from /home/thomas/work/computing/root_5_34_18/lib/libCore.so
#4  <signal handler called>
#5  0x00007fcf77f2df1e in TTreePlayer::CopyTree(char const*, char const*, long long, long long) () from /home/thomas/work/computing/root_5_34_18/lib/libTreePlayer.so
#6  0x00007fcf79dc9bcb in Overlap::AddTreesToFiles(TString) () from /home/thomas/work/BRecoDpipi/workdir/../source/lib/libAnalyser.so
#7  0x00007fcf79dcfe2e in Analyser::DumpFitTrees(Modes::Mode, bool, TString, TString, TString) () from /home/thomas/work/BRecoDpipi/workdir/../source/lib/libAnalyser.so
#8  0x00007fcf79ddb25f in G__AnalyserDict_601_0_22(G__value*, char const*, G__param*, int) () from /home/thomas/work/BRecoDpipi/workdir/../source/lib/libAnalyser.so
#9  0x00007fcf81433acb in Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) () from /home/thomas/work/computing/root_5_34_18/lib/libCint.so
#10 0x00007fcf814d9451 in G__execute_call () from /home/thomas/work/computing/root_5_34_18/lib/libCint.so
#11 0x00007fcf814d983e in G__call_cppfunc () from /home/thomas/work/computing/root_5_34_18/lib/libCint.so
#12 0x00007fcf814ba17c in G__interpret_func () from /home/thomas/work/computing/root_5_34_18/lib/libCint.so
#13 0x00007fcf814a6636 in G__getfunction () from /home/thomas/work/computing/root_5_34_18/lib/libCint.so
#14 0x00007fcf81592170 in G__getstructmem(int, G__FastAllocString&, char*, int, char*, int*, G__var_array*, int) () from /home/thomas/work/computing/root_5_34_18/lib/libCint.so
#15 0x00007fcf81587100 in G__getvariable () from /home/thomas/work/computing/root_5_34_18/lib/libCint.so
#16 0x00007fcf8147fc72 in G__getitem () from /home/thomas/work/computing/root_5_34_18/lib/libCint.so
#17 0x00007fcf81486384 in G__getexpr () from /home/thomas/work/computing/root_5_34_18/lib/libCint.so
#18 0x00007fcf81509e83 in G__exec_statement () from /home/thomas/work/computing/root_5_34_18/lib/libCint.so
#19 0x00007fcf8146c1c3 in G__exec_tempfile_core () from /home/thomas/work/computing/root_5_34_18/lib/libCint.so
#20 0x00007fcf8146d95e in G__exec_tempfile_fp () from /home/thomas/work/computing/root_5_34_18/lib/libCint.so
#21 0x00007fcf81516ae2 in G__process_cmd () from /home/thomas/work/computing/root_5_34_18/lib/libCint.so
#22 0x00007fcf8310dcca in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /home/thomas/work/computing/root_5_34_18/lib/libCore.so
#23 0x00007fcf830705ca in TApplication::ProcessLine(char const*, bool, int*) () from /home/thomas/work/computing/root_5_34_18/lib/libCore.so
#24 0x00007fcf82cc3bd9 in TRint::HandleTermInput() () from /home/thomas/work/computing/root_5_34_18/lib/libRint.so
#25 0x00007fcf83146e6c in TUnixSystem::CheckDescriptors() () from /home/thomas/work/computing/root_5_34_18/lib/libCore.so
#26 0x00007fcf83148616 in TUnixSystem::DispatchOneEvent(bool) () from /home/thomas/work/computing/root_5_34_18/lib/libCore.so
#27 0x00007fcf830c94c6 in TSystem::InnerLoop() () from /home/thomas/work/computing/root_5_34_18/lib/libCore.so
#28 0x00007fcf830cb1a4 in TSystem::Run() () from /home/thomas/work/computing/root_5_34_18/lib/libCore.so
#29 0x00007fcf8306e92f in TApplication::Run(bool) () from /home/thomas/work/computing/root_5_34_18/lib/libCore.so
#30 0x00007fcf82cc460c in TRint::Run(bool) () from /home/thomas/work/computing/root_5_34_18/lib/libRint.so
#31 0x0000000000400f6c in main ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug 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.
===========================================================
#5  0x00007fcf77f2df1e in TTreePlayer::CopyTree(char const*, char const*, long long, long long) () from /home/thomas/work/computing/root_5_34_18/lib/libTreePlayer.so
#6  0x00007fcf79dc9bcb in Overlap::AddTreesToFiles(TString) () from /home/thomas/work/BRecoDpipi/workdir/../source/lib/libAnalyser.so
#7  0x00007fcf79dcfe2e in Analyser::DumpFitTrees(Modes::Mode, bool, TString, TString, TString) () from /home/thomas/work/BRecoDpipi/workdir/../source/lib/libAnalyser.so
===========================================================

Hello,

I meanwhile found the solution to my problem. In the function GetOverlapTree I called I set some BranchAddresses for the tree. After finishing the function the destination for the BranchAddresses are gone. Including the t->ResetBranchAddresses() fixed the problem. But I am still not sure why this not caused the code to crash for Root 5.28.

Cheers,
Thomas