Hey guys,
so I’ve got something very simple here.
I’m trying to create a class to link up my MonteCarlo simulation program for my thesis to ROOT.
It all compiles and no libraries or includes are missing!
And at destruction of a TFile either as stack or heap I get segmentation violations.
I’ve used numerous g++ compiler versions, and I am now using the icpc & mpiicpc compiler.
I would prefer to create it as heap, beacuse I want to keep my options open to create more than 1 Root File if needed.
I have tried creating&destroying them outside of a class and it works just fine (as you can see).
I don’t know whether this is due to the configuration of the system or my lack of programing skills or intelligence
System specs:
Woodcrest cluster
http://www.rrze.fau.de/dienste/arbeiten-rechnen/hpc/systeme/woodcrest-cluster.shtml (english doc)
SuSE Linux (Enterprise?) x86-64 Kernel 3.0.58-23-default
Intel® C++ Intel® 64 Compiler XE for applications running on Intel® 64, Version 12.1.3.293 Build 20120212
Copyright © 1985-2012 Intel Corporation. All rights reserved.
ROOT 5.34/01 (branches/v5-34-00-patches@45034, Aug 31 2012, 20:01:00 on linuxx8664icc)
accessed via SSH from MacOSX 10.6.8 (I do not think this is at all relevant.)
I have shortened everything to the obvious problem. The class is actually more extensive.
#Makefile
CXX = icpc
HCC = mpiicpc
# name of setup
BINARYNAME = RootLink
ROOTLIB = $(shell root-config --libs)
# compiler and linker option
OPTIMIZE = -O2 -no-gcc -Wall $(shell root-config --cflags)
LDOPT = $(ROOTLIB) -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree \
-lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -limf -lm -ldl
#for SunOS:
#LDOPT = -lm -lsocket -lnsl
all:single
##parallelFast parallelStable GUI;
single:
$(CXX) $(OPTIMIZE) $(BINARYNAME).cpp -o link $(LDOPT)
clean:
@rm -rfv link *.root
// RootLink.cpp
#include <iostream>
#include <fstream>
//#include <cmath>
#include "TROOT.h"
#include "TSystem.h"
#include "TObject.h"
#include "TRef.h"
#include "TMacro.h"
#include "TApplication.h"
#include "Riostream.h"
#include "TFile.h"
#include "TTree.h"
#include "TH1.h"
#include "TNtuple.h"
class RootLink{
public:
RootLink(std::string _filename);
~RootLink();
private:
TFile f;
//TFile *f;
};
RootLink::RootLink(std::string _filename){
_filename=_filename+".root";
std::cout << "Set filename..." <<endl;
TFile f(_filename.c_str(),"RECREATE");
//TFile *f = new TFile(_filename.c_str(),"RECREATE");
}
RootLink::~RootLink(){
f.Close();
//f->Close();
}
#ifndef __CINT__
int main(){
std::cout << "Gernerating stacked ROOT file..." <<endl;
TFile f("abc.root","RECREATE");
std::cout << "ROOT file created ..." <<endl;
f.Close();
std::cout << "File opener destroyed ..." <<endl;
std::cout <<endl;
std::cout << "Gernerating heaped ROOT file..." <<endl;
TFile *file = new TFile("def.root","RECREATE");
std::cout << "ROOT file created ..." <<endl;
file->Close();
std::cout << "File opener destroyed ..." <<endl;
std::cout <<endl;
std::cout << "Gernerating classed ROOT file..." <<endl;
RootLink B("spec");
std::cout << "ROOT file created ..." <<endl;
B.~RootLink();
//B->makeSpecFile();
//delete B;
std::cout << "File opener destroyed ..." <<endl;
return 0;
}
#endif
[color=#FF0040]My segmentation violation looks like this:[/color]
*** Break *** segmentation violation
===========================================================
There was a crash (#5 0x00007fb49686fed7 in SigHandler(ESignals) () from /home/vault/capm/shared/apps/root/5.34.01_intel12.1.5_20120612/lib/root/libCore.so).
This is the entire stack trace of all threads:
===========================================================
#0 0x00007fb491601715 in waitpid () from /lib64/libc.so.6
#1 0x00007fb491598e31 in do_system () from /lib64/libc.so.6
#2 0x00007fb4968737f9 in TUnixSystem::Exec(char const*) () from /home/vault/capm/shared/apps/root/5.34.01_intel12.1.5_20120612/lib/root/libCore.so
#3 0x00007fb49687a956 in TUnixSystem::StackTrace() () from /home/vault/capm/shared/apps/root/5.34.01_intel12.1.5_20120612/lib/root/libCore.so
#4 0x00007fb49686ff8a in TUnixSystem::DispatchSignals(ESignals) () from /home/vault/capm/shared/apps/root/5.34.01_intel12.1.5_20120612/lib/root/libCore.so
#5 0x00007fb49686fed7 in SigHandler(ESignals) () from /home/vault/capm/shared/apps/root/5.34.01_intel12.1.5_20120612/lib/root/libCore.so
#6 0x00007fb4968700bc in sighandler(int) () from /home/vault/capm/shared/apps/root/5.34.01_intel12.1.5_20120612/lib/root/libCore.so
#7 <signal handler called>
#8 0x00007fb4957d246e in TFile::Close(char const*) () from /home/vault/capm/shared/apps/root/5.34.01_intel12.1.5_20120612/lib/root/libRIO.so
#9 0x0000000000403cce 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.
===========================================================
#8 0x00007fb4957d246e in TFile::Close(char const*) () from /home/vault/capm/shared/apps/root/5.34.01_intel12.1.5_20120612/lib/root/libRIO.so
#9 0x0000000000403cce in main ()
===========================================================