A new class G4AssemlyStore has been added to the Geant 4-10.5 in order to release all G4AssemblyVolume objects. The destructor of class G4AssemblyVolume will release all the PhysicalVolumes in this AssemblyVolume. However, all G4VPhysicalVolumes will be released by the destructor of class G4PhysicalVolumeStore at the end of the program. If the destructor of the class G4PhysicalVolumeStore is called before the destructor of the class G4AssemlyStore, then the PhysicalVolume in each existing Assembly will be deleted twice, which will result in a segmentation fault (core dumped). For example, I use the following code: 317 //in G4VPhysicalVolume* G02DetectorConstruction::Construct() 318 319 G4AssemblyVolume *plateAV1=new G4AssemblyVolume; 320 321 G4Box * experimentalHallBox = 322 new G4Box("ExpHallBox", fExpHall_x, expHall_y, expHall_z); 323 G4LogicalVolume * experimentalHallLV = 324 new G4LogicalVolume(experimentalHallBox, fAir, "ExpHallLV"); 325 G4PVPlacement * experimentalHallPhys = 326 new G4PVPlacement(0, G4ThreeVector(0.0,0.0,0.0), experimentalHallLV, 327 "ExpHallPhys", 0, false, 0); 328 The first G4AssemblyVolume was created before the first G4VPlacement, so the static G4AssemblyStore assemblyStore was created before the static G4PhysicalVolumeStore worldStore, causing the G4AssemblyStore destructor to be called after the G4PhysicalVolumeStore. The result is that at the end of the program, the following error occurs: Graphics systems deleted. Visualization Manager deleting... Segmentation fault (core dumped) Suggested fix: 158 G4AssemblyStore* G4AssemblyStore::GetInstance() 159 { 160 if(!fgInstance) G4PhysicalVolumeStore::GetInstance(); //Make sure static 161 static G4AssemblyStore assemblyStore; //G4AssemblyStore is created 162 if (!fgInstance) //after static G4PhysicalVolumeStore. 163 { 164 fgInstance = &assemblyStore; 165 } 166 return fgInstance; 167 }
Thanks for reporting this case. I will look at it.
This is now fixed in the development version and will be available in a future patch release.