Some possible bug in class TFumili?

Hi Rooters,

I am using TFumili class (not Fumili2 from the minuit2 package) to do some detector calibration recently. I made use of the methods SetData() and SetUserFunc() to set data point and model function respectively. The code was compiled successfully but crashed during execution. I then carefully checked the source code of relevant methods of TFumili class and found the following which I think might be some bug:

  1. In the SGZ() method there is a block of code like this:
   for (l=0;l<fNED1;l++) { // cycle on all exp. points

      /* Some code in this loop*/

      l = 0;
      for (i=0;i<n;i++)
         for (j=0;j<=i;j++)
            fZ[l++] += df[i]*df[j];
      k2 += fNED2;
   } /* loop ends */

l is a loop variable. However, l is set to 0 and represents the indices of elemets of array fZ towards the end of the loop, which causes l to end up with always the same value after one execution of the code in the loop. In that way, the loop might never end. I think it makes more sense if a new variable is defined to serve the purpose of looping over the array elements.

  1. In the ExecuteCommand() method there is such a code block:
Int_t TFumili::ExecuteCommand(const char *command, Double_t *args, Int_t nargs){

   /* Some code */

   if (nargs<=0) fCmPar[0] = 0;
   Int_t i;
   for(i=0;i<fMaxParam;i++) {
   if(i<=nargs) fCmPar[i] = args[i];

nargs is the number of elements in the array args from my understanding, so I did the following in my code:

But this turns out to crash the program since it tries to access the array element args[0], but args is NULL pointer. I believe it makes more sense if we change


We want to access the array args only when nargs>0.

I modified the code accordingly and the program works fine after that. Thus I believe they might be some bug and it is better to fix them.
BTW, I am using root 5.34 now. But I checked the code in root 6.02 and they are the same as that in 5.34.



Thank you for the report. It is correct, this is bug. I will commit now a fix in both 5.34 and 6 revisions of ROOT

Best Regards