GSI Forum
GSI Helmholtzzentrum für Schwerionenforschung

Home » PANDA » PandaRoot » Bugs, Fixes, Releases » Bug in PndEmcHitProducer
Re: Bug in PndEmcHitProducer [message #10530 is a reply to message #10529] Wed, 14 April 2010 11:40 Go to previous messageGo to previous message
M.Babai is currently offline  M.Babai
Messages: 46
Registered: January 2008
Location: Netherlands
continuous participant
From: *KVI.nl
Hi!,

This problem is now solved and the corrected code is available in trunk.
In the original code the following was declared and used without proper initialization:

map<Int_t, Float_t> fTrackEnergy;
map<Int_t, Float_t> fTrackTime;  //time of first point
map<Int_t, std::vector <Int_t> > fTrackMcTruth;  //McTruth
fTrackEnergy.clear();
fTrackTime.clear();
fTrackMcTruth.clear();
.........
.........
point  = (PndEmcPoint*) fPointArray->At(iPoint);
fTrackEnergy[point->GetDetectorID()] += point->GetEnergyLoss();
point_time=point ->GetTime();
if (point_time < fTrackTime[point->GetDetectorID()])
    fTrackTime[point->GetDetectorID()] = point_time;


In the lines above we can see a comparison and a "+=" operation on not initialized member of the map which has(might have) an undefined state.
Another point, which is (in this case) a matter of taste and beauty, is the declaration of:
PndEmcPoint* point = NULL;
map<Int_t, Float_t>::const_iterator p;
outside the loop. In this case they are not leading into wrong computations but potentially they can, as their values are changed inside the loop.

Greets,
/M

[Updated on: Wed, 14 April 2010 11:43]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: *** glibc detected *** double free or corruption (out): 0x0a0c66f0 ***
Next Topic: Genfit server is down
Goto Forum:
  


Current Time: Mon Dec 06 00:23:01 CET 2021

Total time taken to generate the page: 0.01920 seconds