Root crashes on running compiled code

Bonjour,
I am working on MacOS X 10.9.5
I use root as a library to run analysis codes.
It used to work fine :slight_smile: . But, by mistake I remove Xcode from my computer. Since then I was not able to recover a stable installation.
My last try was :
Install command line tools
install last XQuartz version (2.7.7)
then install last XCode (6.1)
Trash previous root installation directory
Download root_v5.34.21.source.tar.gz, decompress, extract, ./configure, make.
configuration and compilation work fine.
my .cshrc includes :
setenv ROOTSYS /Volumes/AliBaba/Codes/ExternLib/root/
source /Volumes/AliBaba/Codes/ExternLib/root/bin/thisroot.csh $ROOTSYS

after that, the root software execute fine.

But after clean install and recompilation of my analysis codes none of them work.
Compilation shows no error.

Running them, the program crashes in the root eps drawing routines:

MacDom.domino> AnalyseDO2Run54 Run54Proc.root Run54Proc
On excecute: AnalyseDO2Run54 Run54Proc.root Run54Proc
Nbre d’Evt dans le Run: 41303
Info in TCanvas::Print: eps file ./eps/Signal_YAP_Run54Proc.eps has been created
-149.660000*CInt[0]>>hYAP_CInt_keV

*** Break *** segmentation violation
Generating stack trace…
0x0000000107a6880b in TDirectoryFile::Get(char const*) (in libRIO.so) + 219
0x000000010936f6af in TSelectorDraw::Begin(TTree*) (in libTreePlayer.so) + 4543
0x000000010939ed25 in TTreePlayer::Process(TSelector*, char const*, long long, long long) (in libTreePlayer.so) + 149
0x0000000109398219 in TTreePlayer::DrawSelect(char const*, char const*, char const*, long long, long long) (in libTreePlayer.so) + 1945
0x0000000106b5df1e in main (in AnalyseDO2Run54) (AnalyseDO2Run54_DY.cpp:161)
0x00007fff92f6a5fd in start (in libdyld.dylib) + 1
AnalyseDO2Run54(71227,0x7fff77291310) malloc: *** mach_vm_map(size=7307499905230274560) failed (error code=3)
*** error: can’t allocate region
*** set a breakpoint in malloc_error_break to debug

Can you help me?
Best regards.
Dominique Yvon

Following is the program code I am running:

// Version Unix
int main( int narg, const char *argv[] )
{ string fentree, RacFichSort; // Fichier ROOT entrée et sortie
if( narg != 3 ) {
cout<<“Erreur au lancement de AnalyseDO2Run54”<<endl;
cout<<“syntaxe attendue: AnalyseDO2Run54 chemin/fichierProc.root RacNomFichSortie " <<endl;
cout<<“le programme s’arrete”<<endl;
exit(-1);
}
else {
fentree = argv[1];
RacFichSort = argv[2];
cout<<“On excecute: “<< argv[0] <<” \t”<< argv[1] <<” \t"<< argv[2] <<endl;
}

// Fichier entrée
TFile *fe = new TFile(fentree.c_str(), "read");
if (fe->IsZombie())
{
    cout << "PROBLEME pas de fichier root correspondant a "
    << fentree
    << endl;
    exit(-1);
}
TTree *te = (TTree* ) fe->Get("tsortie");

string ChemFichEPS = "./eps/"; 
// Definition des tableaux de résultats de la production
double Amp[NbrChan], AmpFit[NbrChan], TEmil[NbrChan], TPerC[NbrChan], TRise[NbrChan], MoyLB[NbrChan], SigLB[NbrChan], Cint[NbrChan];
int NoEvt;

te->SetBranchAddress("NoEvt", &NoEvt);      // No de l'évènement dans le run
te->SetBranchAddress("MoyLB", MoyLB);
te->SetBranchAddress("SigLB", SigLB);       // ecart type de la ligne de base
te->SetBranchAddress("Amp",   Amp);         // amplitude des pulses
te->SetBranchAddress("AmpFit", AmpFit);     // amplitude des pulses fittée sur trois points autour du max
te->SetBranchAddress("TEmil", TEmil);       // temps de declenchement en ns methode Emilie
te->SetBranchAddress("TPerC", TPerC);       // temps de declenchement Ă  TimeSeuil % du maximum
te->SetBranchAddress("TRise", TRise);       // temps de montee entre 20% et 80% du max en ns
te->SetBranchAddress("CInt", Cint);         // integrale sous le pulse (V.ns)

int NbEvt = te->GetEntries();
cout <<"Nbre d'Evt dans le Run: "<< NbEvt << endl;

// Definition du fichier de Resultats du run
string FileNameResults = "./Res/"; FileNameResults += RacFichSort; FileNameResults+= "Res.txt";
ofstream StrRes(FileNameResults);
StrRes.precision(4);
StrRes<<scientific;

// On commence par regarder le signal du YAP
string HHeader = "Signal YAP -"; 
TCanvas *c0 = new TCanvas("c0", HHeader.c_str(), 10, 10, 1800, 1200);
c0->Divide(3,3);

c0->cd(1);
te->Draw("MoyLB[0]>>hMoyLB_YAP(100,-0.005,0.005)");
c0->cd(2);
te->Draw("SigLB[0]>>hSigLB_YAP(100,0.,0.0025)");
c0->cd(3);
te->Draw("TRise[0]>>hTRise_YAP(250,0.,5.)");
c0->cd(4);
te->Draw("Amp[0]>>hAmp_YAP(250,-0.5.,0.)");
c0->cd(5);
te->Draw("CInt[0]>>hCInt_YAP(250,-15.,0.)");
c0->cd(6);
te->Draw("TEmil[0]>>hTEmil_YAP(250,100.,200.)");
c0->cd(7);
te->Draw("TRise[0]:TPerC[0]>>hTRiseVsTPerC_YAP(50,100.,200., 50,0.,5.)","", "CONTZ");
c0->cd(8);
te->Draw("TRise[0]:Amp[0]>>hTRiseVsAmp_YAP(50,-0.5,-0.,50,0.,5.)","", "CONTZ");
c0->cd(9);
te->Draw("TRise[0]:TEmil[0]>>hTRiseVsTEmil_YAP(50,100.,200., 50,0.,5.)","", "CONTZ");
// Sauvegarde de l'histograme
{   string FilSave = ChemFichEPS +"Signal_YAP_"; FilSave += RacFichSort; FilSave += ".eps";
    c0->SaveAs( FilSave.c_str() );
}

// Travail sur l'etalonnage YAP
TFile StoreFile("SpecFondRadInYAP.root","recreate");
HHeader = "Etalonnage YAP "; 
TCanvas *c11 = new TCanvas("c11", HHeader.c_str(), 10, 10, 600, 400);

//double CalVal_YAPAmp = -4.3135e3;   // keV/Volt, Valeur Run53
double CalVal_YAPCint = -1.4966e2;    // keV/Volt/ns, Valeur Run53

// On affiche le spectre Ă©talonne
TH1F hYAP_keV("hYAP_CInt_keV","Spectre YAP integrale pulse Etalonne", 300, 0., 1500.);
char CalVal[10]; sprintf(CalVal, "%f", CalVal_YAPCint);
string toto = CalVal; toto += "*CInt[0]>>hYAP_CInt_keV";    cout<< toto << endl;
te->Draw( toto.c_str());
 
// Sauvegarde des histogrammes
{   string FilSave = ChemFichEPS +"Etalonnage_YAP"; FilSave += RacFichSort; FilSave += ".eps";
    c11->SaveAs(FilSave.c_str());         // THIS IS WHERE THE Program Crashes
}

TH1F hYAP_keVBis("hYAP_CInt_keVBis","Spectre YAP integrale pulse Etalonne", 600, 0., 3000.);
sprintf(CalVal, "%f", CalVal_YAPCint);
toto = CalVal; toto += "*CInt[0]>>hYAP_CInt_keVBis";    cout<< toto << endl;
te->Draw( toto.c_str());

// Sauvegarde des histogrammes
{   string FilSave = ChemFichEPS +"Etalonnage_YAPBis"; FilSave += RacFichSort; FilSave += ".eps";
    c11->SaveAs(FilSave.c_str());
}
.......

Bonjour,
I can’t see what is wrong, but the problem is not where you think it is:

string toto = CalVal; toto += "*CInt[0]>>hYAP_CInt_keV"; cout<< toto << endl;
te->Draw( toto.c_str()); // THIS IS WHERE THE Program Crashes

// Sauvegarde des histogrammes
{ string FilSave = ChemFichEPS +"Etalonnage_YAP"; FilSave += RacFichSort; FilSave += ".eps";
c11->SaveAs(FilSave.c_str()); // THIS IS NOT WHERE THE Program Crashes

As you can see in the stack trace, the problem occurs during the TTree::Draw:

Generating stack trace...
0x0000000107a6880b in TDirectoryFile::Get(char const*) (in libRIO.so) + 219
0x000000010936f6af in TSelectorDraw::Begin(TTree*) (in libTreePlayer.so) + 4543
0x000000010939ed25 in TTreePlayer::Process(TSelector*, char const*, long long, long long) (in libTreePlayer.so) + 149
0x0000000109398219 in TTreePlayer::DrawSelect(char const*, char const*, char const*, long long, long long) (in libTreePlayer.so) + 1945

Hope this helps
John

Just a thought:
if you replace

TH1F hYAP_keV("hYAP_CInt_keV","Spectre YAP integrale pulse Etalonne", 300, 0., 1500.);
char CalVal[10]; sprintf(CalVal, "%f", CalVal_YAPCint);
string toto = CalVal; toto += "*CInt[0]>>hYAP_CInt_keV"; cout<< toto << endl;
te->Draw( toto.c_str());

by

char CalVal[10]; sprintf(CalVal, "%f", CalVal_YAPCint);
string toto = CalVal; toto += "*CInt[0]>>hYAP_CInt_keV(300, 0., 1500.)"; cout<< toto << endl;
te->Draw( toto.c_str());

i.e. let the TTree::Draw generate the histogram as in your previous TTree::Draw calls,
does it still not work?