Created attachment 644 [details] Macro, detector construction and output files to run with TestEm1 A detailed description is on the Geant4 forum here: https://geant4-forum.web.cern.ch/t/segmentation-fault-after-changing-material-of-a-volume-back-to-the-first-defined-material-for-this-volume/3267 A segmentation fault takes place when an object's material is changed, and then changed back to the original material. The problem can be reproduced by using TestEm1 with the attached files: After some time I tried to reproduce my problem using the TestEm1 example and finally I got it. But it is a mistery to me. I describe it below in four runs: Description: I used the version 10.06.p02 with your mac file: moralles.mac.txt RESULT: OK, no errors. I changed from emstandard_opt0 to emstandard_opt4. RESULT: OK, no errors. After this I have changed the SetMaterial method to reproduce the way I do it in my code: I have commented G4RunManager::GetRunManager()->PhysicsHasBeenModified(); and I have included G4RunManager::GetRunManager()->ReinitializeGeometry(); So, the Construct() will be called again after material changes. I used your mac file: moralles.mac.txt RESULT: OK, no errors. I changed from emstandard_opt0 to emstandard_opt4. RESULT: SEGMENTAION FAULT when the material come back to G4_Al. So, there is a combination to produce the error: G4RunManager::GetRunManager()->ReinitializeGeometry(); with emstandard_opt4 with material change. I hope someone can explain what what happens in this case.
Hello, problem is in your modification inside DetectorConstruction.cc - the line you commented out is needed. In the example itself I do not see any crash if in several runs for this example the 1st material is set (I have checked this with candidate version of Geant4 cand01). VI
Hello, to say more: when a material is changed it is not "geometry change" but is "physics change" situation in Geant4, because change of material means different cross sections, dEdx, other values, which should be prepared for the new run. VI
(In reply to Vladimir.Ivantchenko from comment #2) > Hello, > > to say more: when a material is changed it is not "geometry change" but is > "physics change" situation in Geant4, because change of material means > different cross sections, dEdx, other values, which should be prepared for > the new run. > > VI Dear Vladimir, Many thanks for your input. My code is now working following the addition of G4RunManager::GetRunManager()->PhysicsHasBeenModified(); before the G4RunManager::GetRunManager()->ReinitializeGeometry(); line. Kind regards, David