| Summary: | segmentation fault adding new volume between 1st and 2nd run | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | nanjo |
| Component: | run | Assignee: | kurasige |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | Makoto.Asai, nanjo |
| Priority: | P2 | ||
| Version: | 7.1 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
As you pointed out, a segmentation fault occurs if a new material is added after the first run. It is possible to avoid this problem by rebuilding the Energy Loss table if new elements are added. Fixed version of G4VRangeToEnergyConverter will be available soon (a patch for release 8.0) |
Dear geant4 developers, I added a new volume between 1st and 2nd run, but it made a segmentation fault. I think one reason is not updated lossTables. (I use geant4.8.0.) A call tree after beamOn is as follows. void G4RunManager::BeamOn(G4int n_event,const char* macroFile,G4int n_select) void G4RunManager::RunInitialization() G4bool G4RunManagerKernel::RunInitialization() G4RunManagerKernel::UpdateRegion() G4ProductionCutsTable::UpdateCoupleTable(G4VPhysicalVolume* currentWorld) G4VRangeToEnergyConverter::Convert(G4double rangeCut, const G4Material* ) Here, a lossTable for each material is built only at the beginning of the first run, which can be seen in processes/cuts/src/G4VRangeToEnergyConverter.cc at line number 109, "if (theLossTable ==0) BuildLossTable();". When a new volume (which uses new materials) is added between 1st and 2nd run, the lossTable which was already built at the 1st run is not updated. So at the 2nd run, no lossTable corresponding to the G4Element object used in the newly added volume exists. Then a segmentation violation is occured. The similar thing is also occured when G4LogicalVolume::UpdateMaterial(G4Material *pMaterial) is called after 1st run. One solution might be to call BuildLossTable() at every run. But it is not enough. The lossTable is rebuild only when (size_t(NumberOfElements) != G4Element::GetNumberOfElements()). 245 void G4VRangeToEnergyConverter::BuildLossTable() 246 { 247 // Build dE/dx tables for elements 248 if (size_t(NumberOfElements) != G4Element::GetNumberOfElements()) { 249 if (theLossTable!=0) delete theLossTable; 250 theLossTable =0; 251 NumberOfElements = 0; 252 } 253 254 if (NumberOfElements ==0) { ............. A solution may be to rebuild lossTables every run or to intorduce a flag to force rebuilding lossTables. I am not sure it is enough to fix the problem. Is there some way to avoid such problem in adding new volume after 1st run? If it is really a problem, could you please fix it? Best regards, Hajime Nanjo Department of Physics, Kyoto University Hajime Nanjo