Re: Crash:illegal pointer to class object (not happened before!)

From: Nick van Eijndhoven <nickve.nl_at_gmail.com>
Date: Tue, 21 Apr 2009 10:52:22 +0200


Hi Deepak,In your "for loop statement" you have to define "i" like e.g.

for (Int_t i=1; i<=31; i++)

Then the complaint about the automatic var. initialisation will also disappear.

Cheers,
Nick.

On Tue, Apr 21, 2009 at 1:22 AM, Deepak Kar <dkar_at_phys.ufl.edu> wrote:

> Hello folks!
>
> I am sure I am missing something trivial here. I had a bunch of codes
> before, and they ran fine. After a while I am trying to run them,
> without changing anything to my knowledge. They are all crashing with
> the same error, and this just a simple example.
>
> {
> gROOT->Reset();
>
> TFile *f= new TFile("gen.root");
> TProfile *hist2=(TProfile*)
> gDirectory->Get("Ana/dyjet/Hist/dyjet_Pnchg5pairpt2");
>
> TFile *f=new TFile("ze_tlt.root");
> TProfile *hist3=(TProfile*)
> gDirectory->Get("Ana/dyjet/Hist/dyjet_Pnchg5pairpt2");
>
>
> for(i=1;i<=31;i++){
> xbin1= hist2->GetBinCenter(i);
> gen = hist2->GetBinContent(i);
> sim = hist3->GetBinContent(i);
> printf("MC bin, Gen/SIM = %f, %f,\n",gen/sim);
> }
> }
>
> It crashes with:
>
> Warning: Automatic variable i is allocated draw_ratio.C:19:
> Error: illegal pointer to class object hist2 0x0 1046 draw_ratio.C:20:
> Warning: Automatic variable xbin1 is allocated draw_ratio.C:20:
> Error: Undeclared variable xbin1 draw_ratio.C:20:
> *** Interpreter error recovered ***
>
> The .root files are all there, so are the histograms in that path.
>
> Thanks a lot for any input.
>
> Deepak
>
>
> --
> Deepak Kar
> Postdoctoral Fellow, Experimental Particle Physics (ATLAS/CDF)
> Institut für Kern- und Teilchenphysik
> TU Dresden
> Homepage: http://iktp.tu-dresden.de/~dkar/
>
>

-- 
Dr. Nick van Eijndhoven
nickve.nl@gmail.com   http://sites.google.com/site/nickveweb
skype: nickve.nl          gsm: +31-6-40181589
Utrecht University, Dept. of Physics and Astronomy
Princetonplein 5, 3584 CC Utrecht, The Netherlands
tel: +31-30-2532331   fax: +31-30-2518689

"In the beginning there was nothing, which exploded".
Received on Tue Apr 21 2009 - 10:52:45 CEST

This archive was generated by hypermail 2.2.0 : Tue Apr 21 2009 - 11:50:02 CEST