Error reading back a class

Hello,
I made two classes, one vector class TVectorDVCS to which I added functions a la SIGMA since I am working with someone who like its notation and a class which contains and uses this former class it is named test since I stripped most of the code to debug it.
I had some trouble with reading back the object test.
I traced the segmentation fault to the vectors fInf_phi et fSup_phi streamers, if I comment those out, the object is read.
The odd thing is the other vectors of the class are read and written fine.
I found a fix to this problem by making the vector bigger :
one can see that a the line in test.C

Int_t bigger=3;// if this number is less than 4 the vector
//inf_phi and sup_phi crashes when being read out from file
//inf_phi and sup_phi crashes when being read out from file

if I put 4 or more the object can be read, less than 3 it segfaults.

I attached a copy of the directory.
The rootlogon.C should load the two classes and executing testfile.C open a file write the object, closes the file and reopen the file to check the object.

I have been looking for a problem in the different constructors and around most of the code but still have not found the error.
So if you have any ideas, I still would like to understand this error.

I tried this with both version 4.00/08 and 4.04/02

If you try with version 4.04/02 you should replace TVector.h by TVectorD.h to get it to run.

Thank you,

Alexandre
rtalk.tar.gz (9.22 KB)

Hi,

I can not reproduce your problem. Could you try it out with valgrind?
Use ROOT 4.04/02a and make sure all the library are rebuilt.

Cheers.
Philippe.

Thank you for the quick reply,
actually the testfile does not crash, but you have to do something with the object to get it to be read and to crash.
I added the use of the object to the script so if the attached script does not seg fault I definitely have a problem on all my root installs.

I don’t understand what you mean by valgrind.
And I am not sure where to find the 4.04-02a version, I made a checkout with the tah 4-04-02a and compiled it but still got the problem.
I also tried with the latest CVS version too.

Could you try this script and tell me if this work ?

Thank you,

Alexandre
testfile.C (219 Bytes)

Hi,

There are 2 issues (one is an error in TVectorD that will be corrected soon).
The other is that you default constructor (test::test) is actually calling test::init() that does load the information from your binary file.
You should not that the ROOT I/O has to call the default constructor before loading the object from file. So in your case when you load from a ROOT file, you (seemingly) read the information twice (from 2 different places!). In addition, Moving the Init out of the default constructor also solved the problem!!

Cheers,
Philippe

Thank you for your help Philippe !

Best regards,

Alexandre