Message: G4VUserTrackInformation is broken (or at least VERY fragile) Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None G4VUserTrackInformation is broken (or at least VERY fragile) 

Forum: Event and Track Management
Date: 20 May, 2003
From: Tom Roberts <Tom Roberts>

The interactions between G4Track and G4VUserTrackInformation are broken, and can easily lead to a segment violation. The problem is that G4Track::operator=() copies the pointer fpUserInformation and G4Track::~G4Track() deletes it. So if you ever copy one track to another and you have set a G4VUserTrackInformation pointer into the track, your program will die because it gets deleted twice.

Workaround: after copying the track to newTrack, do

IMHO the fix is to change G4Track::operator=() to zero the pointer. Note that it does not know how to construct a new instance of the user's class. This will probably be OK, because the user probably set the pointer in UserTrackingAction or UserSteppingAction, and the new track will get a new UserTrackInfo object in the same way the original one did (well, at least MY code works that way (:-)). Note the copy constructor uses operator=(), as does CopyTrackInfo().

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Ok: Re: G4VUserTrackInformation is broken (or at least VERY fragile)   (Makoto Asai - 20 May, 2003)
 Add Message Add Message
to: "G4VUserTrackInformation is broken (or at least VERY fragile)"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]