Re: TMinuit dtor crash

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jan 10 2000 - 14:06:52 MET


Hello Yves,
I looked into your code. When you use the gradient option, you use
indices
out of the array boundary in
AliPHOSTrackSegmentMakerv1::UnfoldingChiSquare.
You have a piece of code that looks like:

      iParam = 0 ;
      while(iParam < NPar ){
	.....
	Grad[iParam++] += Epar * shape * deriv * (xpar - xDigit)
;	                 Grad[iParam++] += Epar * shape * deriv * (zpar -
zDigit) ;
	Grad[iParam++] += shape ;
      }
Clearly iParam will be bigger than NPar.
Fix your algorithm.

Rene Brun


Yves SCHUTZ wrote:
> 
> Hi Folks,
> 
> I am fighting with a seemingly TMinuit problem. I
> am using it within the aliroot context and root
> 2.23/08 on a Linux PC. He re is the error message:
> 
> Fatal in <operator delete>: storage area
> overwritten
> 
> It happens only after several call to the
> minimzation.
> 
> Everything goes allright if I do not calculate my
> own gradient, i.e., remove le line :
> 
> gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ;   //
> force TMinuit to use my gradient
> 
> Next you find the backtrace from the debugger and
> the relevant part of the source code.
> 
> Help is welcome .... thanks ..... Yves
> 
> ============= this is the part of the backtrace
> result =======
> #0  0x441bf111 in __kill ()
> #1  0x441bed66 in raise (sig=6) at
> ../sysdeps/posix/raise.c:27
> #2  0x441c0447 in abort () at
> ../sysdeps/generic/abort.c:88
> #3  0x42d613cd in TUnixSystem::Abort ()
> #4  0x42c5159a in DefaultErrorHandler ()
> #5  0x42c51650 in ErrorHandler ()
> #6  0x42c51748 in Fatal ()
> #7  0x42bbc0fa in __builtin_delete ()
> #8  0x42bbc228 in __builtin_vec_delete ()
> #9  0x43526ade in TMinuit::DeleteArrays ()
> #10 0x43526017 in TMinuit::~TMinuit ()
> #11 0x41883abb in
> AliPHOSTrackSegmentMakerv1::FindFit ()
> #12 0x41884d93 in
> AliPHOSTrackSegmentMakerv1::UnfoldClusters ()
> etc.......
> 
> ============= this is part of the code relevant to
> TMinuit ========
>   TMinuit Minuit(NPar) ;
> 
>   gMinuit->SetPrintLevel(-1) ;           // No
> Printout
>   gMinuit->SetFCN(UnfoldingChiSquare) ;  // To set
> the address of the minimization function
>   gMinuit->SetObjectFit(emcRP) ;         // To
> tranfer pointer to UnfoldingChiSquare
> 
>   gMinuit->mnparm(index, "x",  x, 0.1, 0, 0,
> ierflg) ;
>   index++ ;
>   gMinuit->mnparm(index, "z",  z, 0.1, 0, 0,
> ierflg) ;
>   index++ ;
>   gMinuit->mnparm(index, "Energy",  Energy ,
> 0.05*Energy, 0., 4.*Energy, ierflg) ;
>   index++ ;
>   Double_t p0 = 0.1 ; // "Tolerance" Evaluation
> stops when EDM = 0.0001*p0 ; The number of
> function call slightly
>                       //  depends on it.
>   Double_t p1 = 1.0 ;
>   Double_t p2 = 0.0 ;
> 
>   gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ;
> // force TMinuit to reduce function calls
>   gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ;
> // force TMinuit to use my gradient
>   gMinuit->SetMaxIterations(5);
>   gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ;
> // No Warnings
>   gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ;
> // minimize
> 
> ============= this is part of the minimazation
> method relevant to the gradient calculation ======
> 
> void UnfoldingChiSquare(Int_t &NPar, Double_t
> *Grad, Double_t & fret, Double_t *x, Int_t iflag)
> {
>  if(iflag == 2)
>     for(iparam = 0 ; iparam < NPar ; iparam++)
>       Grad[iparam] = 0 ; // Will evaluate gradient
> 
>     if(iflag == 2){  // calculate gradient
>      while(iParam < NPar ){
>        Grad[iParam] = ....
>      }
>    etc ...
>    }
> 
> --
> 
> __________________________________________________________________
> |Yves SCHUTZ  (IN2P3 - CNRS) collaboration
> TAPS/WA98/ALICE         |
> |SUBATECH
> |
> |Ecole des Mines de Nantes Telephone: (+33/0) 2 51
> 85 84 71        |
> |4, rue Alfred Kastler     Fax      : (+33/0) 2 51
> 85 84 79        |
> |F-44070 Nantes cedex 03   e-mail   :
> yves.schutz@subatech.in2p3.fr|
> |__________________________________________________________________|



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:16 MET