Bus error with TTreeFormula on Mac with Leopard

Hi,

I have encountered a problem with TTreeFormula on a MAC running root v5.18.00 under Mac OS X Version 10.5.1. The following example code in conjunction with the attached test file yields a bus error:

  TChain *ch = new TChain("ntuple");
  ch->Add("testfile.root"); 
  TTreeFormula f("fname","nFiles",ch);
 *** Break *** bus error
/Users/kappes/Work/icecube/ana/rootExt/44214: No such file or directory.
Attaching to process 44214.
Reading symbols for shared libraries . done
Reading symbols for shared libraries ................................................................................ done
0x90e5e845 in wait4 ()

========== STACKS OF ALL THREADS ==========

Thread 1 (process 44214 thread 0x20b):
#0  0x90e5e845 in wait4 ()
#1  0x90e5c39b in system$UNIX2003 ()
#2  0x008732c1 in TUnixSystem::StackTrace ()
#3  0x00877535 in TUnixSystem::DispatchSignals ()
#4  0x008776a8 in SigHandler ()
#5  <signal handler called>
#6  0x0384f846 in TTreeFormula::FindLeafForExpression ()
#7  0x03852021 in TTreeFormula::DefinedVariable ()
#8  0x028261c8 in TFormula::Analyze ()
#9  0x02830c18 in TFormula::Compile ()
#10 0x0383b35e in TTreeFormula::Init ()
#11 0x0384ea81 in TTreeFormula::TTreeFormula ()
#12 0x0384eb8a in TTreeFormula::TTreeFormula ()
#13 0x0388311d in G__G__TreePlayer_143_0_29 ()
#14 0x00f90f12 in Cint::G__ExceptionWrapper ()
#15 0x010901ff in G__call_cppfunc ()
#16 0x01067cf5 in G__interpret_func ()
#17 0x010525d0 in G__getfunction ()
#18 0x01011d8e in G__define_var ()
#19 0x010be4f1 in G__exec_statement ()
#20 0x0100919f in G__exec_tempfile_core ()
#21 0x010094d7 in G__exec_tempfile ()
#22 0x010d5e72 in G__process_cmd ()
#23 0x0084dbb4 in TCint::ProcessLine ()
#24 0x007c6321 in TApplication::ExecuteFile ()
#25 0x007c3e46 in TApplication::ProcessLine ()
#26 0x00030077 in TRint::HandleTermInput ()
#27 0x0002f740 in TTermInputHandler::Notify ()
#28 0x000314c4 in TTermInputHandler::ReadNotify ()
#29 0x00877840 in TUnixSystem::CheckDescriptors ()
#30 0x00877f6b in TUnixSystem::DispatchOneEvent ()
#31 0x00810d20 in TSystem::InnerLoop ()
#32 0x00810cbb in TSystem::Run ()
#33 0x007c2ba3 in TApplication::Run ()
#34 0x0003090e in TRint::Run ()
#35 0x00001bae in main ()

However, if I use a TTree instead of a TChain the bus error doesn’t occur:

  TFile *f1 = new TFile("testfile.root");
  TTree *t1 = dynamic_cast<TTree*> gROOT->FindObject("ntuple"));
  TTreeFormula f("fname","nFiles",t1);

Is this a bug?

Regards, Alexander
testfile.root (226 KB)

Hi,

Yes this was a bug, now fixed in the SVN repository.

You can work around the problem by using:TChain *ch = new TChain("ntuple"); ch->Add("testfile.root"); ch->LoadTree(0); TTreeFormula f("fname","nFiles",ch);
Also note that if you are using TTreeFormula with a TChain you need to make to call f.UpdateFormulaLeaves() each time the TChain moves from one file to another (you can check for that by checking where value of ch->GetTreeNumber() changes).

Cheers,
Philippe