[ROOT] Proble with TSPHE ctor

From: Nick West (n.west1@physics.ox.ac.uk)
Date: Fri Mar 05 2004 - 18:04:37 MET


Dear Roottalk,

I want to report what is technically a bug, but won't do it via rootdev
as I just want to
say a big public THANK YOU, mostly to Masa, for fixing things a short
while back

    http://root.cern.ch/root/cinttalk/cint03/0511.html
    
 so that Valgrind:-

    http://valgrind.kde.org/

doesn't choke with cosmetic errors anymore.  Valgrind really is a great
tool.

The bug is in TSPHE.cxx.(cvs version)  In the method:-

  TSPHE::TSPHE(const char *name, const char *title, 
               const char *material, 
               Float_t rmin, 
               Float_t rmax, 
               Float_t themin,
               Float_t themax, 
               Float_t phimin, 
               Float_t phimax)

the member variable fNdiv is initialised by the call:-

  SetNumberOfDivisions (20);

but that code is:-

void TSPHE::SetNumberOfDivisions (Int_t p)
{

    if (GetNumberOfDivisions () == p) return;
    fNdiv=p;
    fNz = Int_t(fAspectRatio*fNdiv*(fThemax - fThemin )/(fPhimax -
fPhimin )) + 1;
    MakeTableOfCoSin();
}

and GetNumberOfDivisions is simply:-

  irtual Int_t   GetNumberOfDivisions () const {return fNdiv;}

so fNdiv is tested before being set.  If you were really unlucky
(randomly initialised to 20) the rest of the code in
SetNumberOfDivisions would be skipped.

When I run Valgrind I still get some errors deep down in CINT and the
data compression code although I am still running 3.10/01 so maybe it
isn't an issue but it raises the question: is Valgrind routinely run on
ROOT and if not would it be a good idea to do so?  If there are benign
problems that cannot easily be fixed it would be great if there were
some official Valgrind suppression file that people could use.

Cheers,

Nick West



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