Continuos crashes on Loading class produced by MakeClass

Dear ROOTers,
I’m trying to do some analysis with a ROOT Tree using the skeleton function produced by TTree::Makeclass. (I already posted other questions about)

I customized the skeleton deriving another class as suggested in a previous post and the i write a preliminar algorithm.
Now the problem is that i suffer continuos crashes (segmentation fault… core dumps…) of ROOT. I thought there was some errors, but now it seems at least C++ correct.

Crashes occurs when i load the derived class with “.L CRAnalyzer.C” (output attached in Crash1.txt),
OR,
if I compile and link dinamically with “.L CRAnalyzer.C+”, when i execute some other instruction or even when i exit the ROOT session (output attached in Crash2.txt).

I attached also the .C and .h files and the root file in the last archive.

I use ROOT v4.03.04, compiled by me (in a custom directory) on a Scientific Linux (maybe SLAC version) pc with gcc vesion 3.2.3
I guess if I did some errors in ROOT installation or if there are some incompatibilities between ROOT and this linux version.

Thx again for help
CR.tar (379 KB)
Crash2.txt (7.55 KB)
Crash1.txt (8.69 KB)

If you look at the code in CR_baseclass.h destructor, you see:
delete fChain->GetCurrentFile();

In your case you are opening the file explictly as an object with
TFile f(“run0.root”);
When exiting from root, this TFile object will be deleted (going out of scope), but it was already deleted by the destructor.
Several solutions, eg use
TFile * f = new TFile(“run0.root”) instead
or in the destructor of your derived class set fChain=0;

Rene