Hi!

I have a macro to read a TTree, that when I include the following code:

``````
...

TFile *p = new TFile(...)

TTree *fout=outTree;

int max=1000;
float sX[max], sN[max];

fout->SetBranchStatus("*",1);
TH1D *dedx=new TH1D ("dedx", "dedx",50,-700,800);

int iev=0;

fout->GetEntry(iev);

for(int i=0; i<1000; i++) {
if(sX[i]>-550 && sX[i]<470) dedx->Fill(sX[i], sN[i]/3.);
}
...
``````

I get the error: free(): invalid next size (fast): 0x00000000145b5320 *** and a big backtrace.

I know there has got to be something wrong with the way I’m using sN and sX, I just dont know exactly what, since max is bigger than the size of GN and SN.

If I do a loop in events, filling an histogram for each and saving the results in another tree, the loop works until the last event, where it gives the same error, or until the numbers of events is too big, and in that instance he just freezes in some event (tipycally around 2000, not that it matters).

I know this should be a very basic problem, but I have read solutions to “free(): invalid next size (fast)” and can’t seem to find the answer.

Thanks

[quote]I know there has got to be something wrong with the way I’m using sN and sX, I just dont know exactly what, since max is bigger than the size of GN and SN.[/quote]Humm … but``` for(int i=0; i<1000; i++) { if(sX[i]>-550 && sX[i]<470) dedx->Fill(sX[i], sN[i]/3.); }```so it seems that you are using random value, aren’t you … or am I missing something?[quote]since max is bigger than the size of GN and SN.[/quote]What is the size of GN and SN?

Thanks,
Philippe.