[ROOT] Bug in THbookFile ctor for non existing files

From: Y. Shitov (shitov@cenbg.in2p3.fr)
Date: Wed Feb 11 2004 - 18:23:43 MET


Dear ROOTers,

I think that I found the bug in THbookFile class. The point is that
  ctor works incorrectly opening non existing HBOOK file.

The following script demonstrates the problem:

void rz() {
  if (!TClassTable::GetDict("THbookFile"))
	 gSystem->Load("libHbook");
  THbookFile *f;
  
  Int_t i=0;
  while (++i) {
    f = new THbookFile("blablabla");
	 cout << i << "-th step: Current directory is '" 
			<< f->GetCurDir() << "'. ";
	 if (i<10)
		cout << "OK." << endl;
	 else {
		cout << "fgLuns stack is full. " 
		  "Can't open any THbookFile objects more..." << endl;
		getchar();
	 }
	 // delete f;
  }
} 

There are two points here:
1. One need to reset non-used item in the	container of  free logical units
fgLuns
(http://root.cern.ch/root/htmldoc/THbookFile.html#THbookFile:fgLuns)
in ctor (see code below).

2. Call of dtor in code above (commented line) leads to crash, because
fList,fKeys
http://root.cern.ch/root/htmldoc/THbookFile.html#THbookFile:fList
http://root.cern.ch/root/htmldoc/THbookFile.html#THbookFile:fKeys
lists deleted there are not initialized in this particular case.

Best wishes,
Yuriy.

Correction proposed for THbookFile::THbookFile(const char *fname, Int_t lrecl)

> if (ier) printf (" Error on hropen was %d \n", ier);
> if (quest[0]) {
> 	 printf("Error cannot open input file: %s\n",fname);
> }
> if (ier || quest[0]) {
    fgLuns[fLun-10]=0; 
> 	 fLun = 0;
> 	 MakeZombie();
> 	 return;
> }



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:05 MET