Directory problem in large file

Hello,

I have a large rootfile in which I am trying to create a bunch of directories. Sometimes the directories already exist so I test for them using TDirectoryFile::GetDirectory before mkdir. I get the following errors when I run my code.

SysError in <TFile::Seek>: cannot seek to position -2095724719 in file data/rootfiles/InSANE72481.-1.root, retpos=-1 (Invalid argument) SysError in <TFile::Seek>: cannot seek to position -2095724602 in file data/rootfiles/InSANE72481.-1.root, retpos=-1 (Invalid argument) SysError in <TFile::Seek>: cannot seek to position -2095724485 in file data/rootfiles/InSANE72481.-1.root, retpos=-1 (Invalid argument) SysError in <TFile::Seek>: cannot seek to position -2095724368 in file data/rootfiles/InSANE72481.-1.root, retpos=-1 (Invalid argument) SysError in <TFile::Seek>: cannot seek to position -2095724251 in file data/rootfiles/InSANE72481.-1.root, retpos=-1 (Invalid argument) SysError in <TFile::Seek>: cannot seek to position -2095724134 in file data/rootfiles/InSANE72481.-1.root, retpos=-1 (Invalid argument) SysError in <TFile::Seek>: cannot seek to position -2095724017 in file data/rootfiles/InSANE72481.-1.root, retpos=-1 (Invalid argument) terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc return status was 6

The offending lines of code are

if ( !(f->GetDirectory(Form("/detectors/bigcal/hist%d",i + 1))) ) { f->mkdir(Form("/detectors/bigcal/hist%d", i + 1)); }
If I comment out the if statement then every works fine! What is going on here?

Thanks!

And your system is? And your ROOT version is? And how big this “large rootfile” is?

BTW you have TFile::Seek mentioned in the error messages, you can easily have a look at the code, which just calls lseek/lseek64/_lseek64i (depending on your system) and can also read a man for lseek family of functions to see when it returns negative value.

Ubuntu 7.10 (I know… old)

5.34.13 (latest)

4.6G

Didn’t find it…