I am running a simulation which includes tracking charged particles through a volume with an associated electric field. I’ve set up my application so that I can adjust the detector voltage with a macro command; I should (and used to be!) successful in doing a whole series of runs in a single job.
Since the voltage is used to build the G4UniformElectricField instance, which is part of the geometry, my job does the necessary clean up and rebuilding of the geometry before each run. The commands I use are
G4RunManager* rm = G4RunManager::GetRunManager(); rm->ReinitializeGeometry(true); rm->GeometryHasBeenModified(); rm->InitializeGeometry();
Unfortunately, after a small number of runs, where this procedure is invoked, my job segfaults within
G4ParallelWorldProcess. The backtrace looks like
(gdb) bt #0 0x00007ffff035c42c in G4LogicalVolume::GetSolid() const () at /afs/slac.stanford.edu/package/geant4/vol51/geant4.10.03.p03/source/geometry/management/src/G4LogicalVolume.cc:368 #1 0x00007ffff039c4d6 in G4PropagatorInField::ComputeStep(G4FieldTrack&, double, double&, G4VPhysicalVolume*) () at /afs/slac.stanford.edu/package/geant4/vol51/geant4.10.03.p03/source/geometry/navigation/src/G4PropagatorInField.cc:217 #2 0x00007ffff03993c0 in G4PathFinder::DoNextCurvedStep(G4FieldTrack const&, double, G4VPhysicalVolume*) () at /afs/slac.stanford.edu/package/geant4/vol51/geant4.10.03.p03/source/geometry/navigation/src/G4PathFinder.cc:1207 #3 0x00007ffff0397492 in G4PathFinder::ComputeStep(G4FieldTrack const&, double, int, int, double&, ELimited&, G4FieldTrack&, G4VPhysicalVolume*) () at /afs/slac.stanford.edu/package/geant4/vol51/geant4.10.03.p03/source/geometry/navigation/src/G4PathFinder.cc:242 #4 0x00007ffff25c3997 in G4ParallelWorldProcess::AlongStepGetPhysicalInteractionLength(G4Track const&, double, double, double&, G4GPILSelection*) () at /afs/slac.stanford.edu/package/geant4/vol51/geant4.10.03.p03/source/processes/scoring/src/G4ParallelWorldProcess.cc:312
The specific line where it fails is
fNavigator->GetWorldVolume()->GetLogicalVolume()-> GetSolid()->DistanceToOut(StartPointA, VelocityUnit) )
GetSolid() call returns a null pointer. This is obviously “impossible” since the world volume has to exist and have been built properly (solid -> LV -> PV). I can’t tell whether the problem is a stale pointer in
fNavigator, or if the current (correct) world-volume or other geometry object has gotten corrupted.
Are there any geometry store, or tracking related, cleanups which I should be doing in my application, beyond telling the RunManager about the geometry change?