Hi,
I created a new version of my class which is stored in a TTree (splitlevel=1) and the new version SegFaults when reading the data of the old version. This happens for all ROOT versions >= 5.10/00 regardless of the used compiler (gcc 3.3.3, 4.0.3 & 4.1.1). The default constructor sets all pointers to NULL.
Version v3 of the class has the form:
class TEyeEvent : public TObject {
public:
TEyeEvent();
protected:
UInt_t fDataPresentBits; // Bit vector for sub-data
private:
TEyeEventHeader *fEventHeader; // Eye event header
TEyeFADCData *fFADCData; // container of FADC traces
TEyePixelList *fPixelList; // (compressed) list ofpixels
TEyePixelData *fPixelData; // container of TMirrorPixelData
TEyeWeatherData *fWeatherData; // old weather station data (unused)
TEyeTriggerData *fTriggerData; // optional trigger info (unused)
TEyeT3Data *fT3Data; // optional T3 info (used)
static unsigned int fgPrintLevel; //! print/verbosity level for TEye* classes
ClassDef(TEyeEvent,(int)EyeEVENTVERSIONv3)
};
Version v4 has fWeatherData removed and v3 replaced by v4.
I managed to create a simple code example which reproduces the error and which is contained in the attachment.
[ul]
mathes@ikauger3:~/src/test/root> ./TestData1 100 1 Data1.root
./TestData1: Writing 100 events to file Data1.root
mathes@ikauger3:~/src/test/root> ./TestData1 0 0 Data1.root
./TestData1: Reading from file Data1.root
… 100 entries found!
mathes@ikauger3:~/src/test/root> ./TestData2 0 0 Data1.root
./TestData2: Reading from file Data1.root
Warning in TClass::TClass: no dictionary for class MData2 is available
… 100 entries found!
*** Break *** segmentation violation
Generating stack trace…
0xb77902c4 in TBuffer::MapObject(TObject const*, unsigned int) + 0xcc from /usr/local/root-5.13.02/lib/libCore.so.5.13
0xb68fbfc9 in TBranchElement::ReadLeaves(TBuffer&) at TBranchElement.cxx:0 from /usr/local/root-5.13.02/lib/libTree.so.5.13
0xb68f298f in TBranch::GetEntry(long long, int) + 0x27b from /usr/local/root-5.13.02/lib/libTree.so.5.13
0xb68f7c6a in TBranchElement::GetEntry(long long, int) + 0x1ac from /usr/local/root-5.13.02/lib/libTree.so.5.13
0xb68f7bef in TBranchElement::GetEntry(long long, int) + 0x131 from /usr/local/root-5.13.02/lib/libTree.so.5.13
0xb693a281 in TTree::GetEntry(long long, int) + 0xc9 from /usr/local/root-5.13.02/lib/libTree.so.5.13
0x0804cf9b in main + 0x325 from ./TestData2
0xb62dc87c in __libc_start_main + 0xdc from /lib/libc.so.6
0x0804cb81 in __gxx_personality_v0 + 0x105 from ./TestData2
Aborted
[/ul]
One possible work-around I found is to check if the pointer passed to TBuffer::MapObject() (or TBufferFile::MapObject()) is aligned or not:
fClassMap->Add(offset,
(obj && obj != (TObject*)-1 && ((((int)obj) % sizeof(void*)) == 0)) ? (Long_t)((TObject*)obj)->IsA() : 0);
instead of
fClassMap->Add(offset,
(obj && obj != (TObject*)-1) ? (Long_t)((TObject*)obj)->IsA() : 0);
But this seems to be a very dirty hack.
Sorry for this lengthy post and probably I have overlooked something in the corresponding release notes
Is there any other, recommended way to overcome this problem ?
Thanks
Hermann-Josef
root-test.tar.gz (3.5 KB)