| Summary: | segmentation fault after UpdateGeometry when HP neutron physics is used | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Cristian Bungau <cbungau> |
| Component: | processes/hadronic | Assignee: | dennis.herbert.wright |
| Status: | RESOLVED WORKSFORME | ||
| Severity: | normal | CC: | kelsey, tkoi |
| Priority: | P5 | ||
| Version: | other | ||
| Hardware: | All | ||
| OS: | All | ||
| URL: | http://hypernews.slac.stanford.edu/HyperNews/geant4/get/eventtrackmanage/981.html | ||
| Attachments: | proposed fix for G4HPNeutronData | ||
Hi Cristian, Thank you for reporting problem. However, I cannot reproduce this problem. In my physics list assigned HP XS and models, And I change detector size and configurations between the runs from command line. And I do not have any problem. So far, it is not clear NeutronHPs are responsible for this or not. And at least under certain condition, its can work without the problem you mentioned So, I changed “component” from NeutornHP to processes/hadronic for involving investigation from more upper level of framework and also modified assigned from me to Dennis. Thank you very much. Tatsumi I see the same sort of crash as reported here, but with some additional lines of information. I'm on MacOSX 10.5.8, GCC 4.0.1, GEANT4 9.4 (original). Using the Shielding physics list, after UpdateGeometry() and beamOn, I get:
terminate called after throwing an instance of 'std::length_error'
what(): vector::reserve
Abort
The traceback from GDB is pretty clear that the error itself originates in NeutronHP:
[...]
#8 0x90601caa in std::__throw_length_error ()
#9 0x0170dfcc in std::vector<double, std::allocator<double> >::reserve ()
#10 0x09ab718a in G4LPhysicsFreeVector::G4LPhysicsFreeVector (this=0x21ed4800, nbin=4074784016, binmin=4.1610583697827065e+149, binmax=4.1610583697827065e+149) at src/G4LPhysicsFreeVector.cc:66
#11 0x09ab7272 in G4LPhysicsFreeVector::G4LPhysicsFreeVector (this=0x21ed4800, nbin=4074784016, binmin=4.1610583697827065e+149, binmax=4.1610583697827065e+149) at src/G4LPhysicsFreeVector.cc:73
#12 0x066dcd9b in G4NeutronHPData::DoPhysicsVector (this=0x69e2a98, theVector=0x186a0) at src/G4NeutronHPData.cc:66
#13 0x0670943d in G4NeutronHPData::MakePhysicsVector (this=0x69e2a98, thE=0xc39d720, theP=0xc34dca0) at G4NeutronHPData.hh:68
#14 0x06709212 in G4NeutronHPInelasticData::BuildPhysicsTable (this=0xc34dca0, aP=@0xb6a1a10) at src/G4NeutronHPInelasticData.cc:86
#15 0x08116e4e in G4CrossSectionDataStore::BuildPhysicsTable (this=0xc092290, aParticleType=@0xb6a1a10) at src/G4CrossSectionDataStore.cc:311
[...]
The strange value for "nbin" at frame #11 makes me think there might be a double-delete going on here. That means that NeutronHP might not have a real bug, but that it's getting stomped on by some other code.
Hi, In my case the error was due to the fact that, in my UpdateGeometry(), I was keeping the same material (made of 2 elements), but I was changing the CONCENTRATION of those elements, so I was creating in fact a new material, which (we could say that) was not pre-defined from the very beginning... So to solve this, I had to define in my DetectorConstruction a very large number of materials to cover many possible concentrations of the two elements inside that particular material. A new material name was used for each concentration configuration. This solved the problem for me. So from my point of view, I am happy to close this problem as solved. Best regards, Cristian Discussed this bug, and my own, with Tatsumi yesterday. NeutronHP requires all materials to be predefined before it is initialized; it does not properly reload its tables for new materials after G4RunManager::GeometryHasBeenModified(), nor after G4RunManager::PhysicsHasBeenModified(). The situation does need to be repaired, but that may require significant work in the code. Created attachment 119 [details]
proposed fix for G4HPNeutronData
We wanted to upgrade our simulation framework with a GDML reader. After reading in the GDML-geometry successfully the program crashed after starting a new run with more or less the same errors mentioned here. So I guess it is the same problem.
I assume that the array (theData) containing information on the G4Elements (materials) for G4HPNeutronData is initialised in the G4HPNeutronData constructor only and is not updated afterwards. When further materials are added and the DoPhysicsVector is called for all materials, also a call for the new materials is tried. But because the array does not have enough entries there were segmentation faults in our case.
I would suggest to check whether the number of entries in the theData array still fits the actual number of G4Elements when DoPhysicsVector is called, and if not so re-initialse the array (see attached patch). For us it seems to have worked.
Cheers,
Tobias
Hi Thank Tobias for reporting possible solution. However, now we understand this problem cannot solve within NeutronHPs. This means some changes in upper framework is definitely required. I will try to explain a little more. NeutronHP has two categories, one is CrossSection, the other is Model. And these two can (should) be used independently (This is one of the most important philosophy of the framework. And both of them needs to read data and build internal data for simulation. In this case, user adds completely new material (possibly including new element) into simulation, then Geant4 kernel requests to rebuild the required data through “BuildPhysicsTable()”. But at the HadronicProcess level, this request is only sent to cross section and not to model. So models cannot rebuild the table. And this is what I mentioned it cannot solve within NeutronHP. I already discuss with Dennis on this issues. I hope it will be modified soon. Tatsumi |
Hi, During the Idle state I want to modify the geometry with the command line. I am modifying only the dimensions of the geometry objects, not the materials. The problem is that I am using a HP neutron physics list and it looks like the neutron data has to be reloaded somehow. The lines in my UpdateGeometry are: void DetectorConstruction::UpdateGeometry() { // Force geometry open G4GeometryManager::GetInstance()->OpenGeometry(); // clean-up previous geometry G4SolidStore::GetInstance()->Clean(); G4LogicalVolumeStore::GetInstance()->Clean(); G4PhysicalVolumeStore::GetInstance()->Clean(); // rebuild and notify run manager G4RunManager::GetRunManager()->DefineWorldVolume(Construct()); G4RunManager::GetRunManager()->GeometryHasBeenModified(); } After a geometry update (in the Idle stat, which works fine as I can see it in my visualisation), if I start a new run I get a segmentation fault: *** Break *** segmentation violation =========================================================== There was a crash (#7 0xb72dfe5d in SigHandler(ESignals) ()). This is the entire stack trace of all threads: =========================================================== #0 0x00ca0422 in __kernel_vsyscall () #1 0x027197d3 in waitpid () from /lib/tls/i686/cmov/libc.so.6 #2 0x026bade3 in ?? () from /lib/tls/i686/cmov/libc.so.6 #3 0x0222f27d in system () from /lib/tls/i686/cmov/libpthread.so.0 #4 0xb72d83ed in TUnixSystem::Exec(char const*) () from /home/cristian/root/lib/libCore.so #5 0xb72dea9d in TUnixSystem::StackTrace() () from /home/cristian/root/lib/libCore.so #6 0xb72dfd55 in TUnixSystem::DispatchSignals(ESignals) () from /home/cristian/root/lib/libCore.so #7 0xb72dfe5d in SigHandler(ESignals) () from /home/cristian/root/lib/libCore.so #8 0xb72d5772 in sighandler(int) () from /home/cristian/root/lib/libCore.so #9 <signal handler called> #10 0x06310c97 in G4NeutronHPData::DoPhysicsVector(G4NeutronHPVector*) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4had_neu_hp.so #11 0x063171ea in G4NeutronHPElasticData::BuildPhysicsTable(G4ParticleDefinition const&) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4had_neu_hp.so #12 0x00c1f76f in G4CrossSectionDataStore::BuildPhysicsTable(G4ParticleDefinition const&) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4hadronic_xsect.so #13 0x003fbd9f in G4HadronicProcess::BuildPhysicsTable(G4ParticleDefinition const&) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4hadronic_mgt.so #14 0x0060296c in G4UHadronElasticProcess::BuildPhysicsTable(G4ParticleDefinition const&) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4hadronic_coherent_elastic.so #15 0x00329e95 in G4VUserPhysicsList::BuildPhysicsTable(G4ParticleDefinition*) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #16 0x0032a6d5 in G4VUserPhysicsList::BuildPhysicsTable() () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #17 0x0031a1c3 in G4RunManagerKernel::BuildPhysicsTables() () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #18 0x0031a320 in G4RunManagerKernel::RunInitialization() () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #19 0x00314a55 in G4RunManager::RunInitialization() () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #20 0x00312e03 in G4RunManager::BeamOn(int, char const*, int) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #21 0x0031b94a in G4RunMessenger::SetNewValue(G4UIcommand*, G4String) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #22 0x0286b72f in G4UIcommand::DoIt(G4String) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4intercoms.so #23 0x0287933c in G4UImanager::ApplyCommand(char const*) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4intercoms.so #24 0x02879536 in G4UImanager::ApplyCommand(G4String) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4intercoms.so #25 0x004888d0 in G4UIterminal::ExecuteCommand(G4String) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4UIbasic.so #26 0x00488753 in G4UIterminal::SessionStart() () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4UIbasic.so #27 0x080502e7 in main () =========================================================== The lines below might hint at the cause of the crash. If they do not help you then please submit a bug report at http://root.cern.ch/bugs. Please post the ENTIRE stack trace from above as an attachment in addition to anything else that might help us fixing this issue. =========================================================== #10 0x06310c97 in G4NeutronHPData::DoPhysicsVector(G4NeutronHPVector*) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4had_neu_hp.so #11 0x063171ea in G4NeutronHPElasticData::BuildPhysicsTable(G4ParticleDefinition const&) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4had_neu_hp.so #12 0x00c1f76f in G4CrossSectionDataStore::BuildPhysicsTable(G4ParticleDefinition const&) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4hadronic_xsect.so #13 0x003fbd9f in G4HadronicProcess::BuildPhysicsTable(G4ParticleDefinition const&) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4hadronic_mgt.so #14 0x0060296c in G4UHadronElasticProcess::BuildPhysicsTable(G4ParticleDefinition const&) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4hadronic_coherent_elastic.so #15 0x00329e95 in G4VUserPhysicsList::BuildPhysicsTable(G4ParticleDefinition*) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #16 0x0032a6d5 in G4VUserPhysicsList::BuildPhysicsTable() () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #17 0x0031a1c3 in G4RunManagerKernel::BuildPhysicsTables() () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #18 0x0031a320 in G4RunManagerKernel::RunInitialization() () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #19 0x00314a55 in G4RunManager::RunInitialization() () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #20 0x00312e03 in G4RunManager::BeamOn(int, char const*, int) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #21 0x0031b94a in G4RunMessenger::SetNewValue(G4UIcommand*, G4String) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4run.so #22 0x0286b72f in G4UIcommand::DoIt(G4String) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4intercoms.so #23 0x0287933c in G4UImanager::ApplyCommand(char const*) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4intercoms.so #24 0x02879536 in G4UImanager::ApplyCommand(G4String) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4intercoms.so #25 0x004888d0 in G4UIterminal::ExecuteCommand(G4String) () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4UIbasic.so #26 0x00488753 in G4UIterminal::SessionStart() () from /home/cristian/geant4/geant4.9.3/lib/Linux-g++/libG4UIbasic.so #27 0x080502e7 in main () =========================================================== Is there anything missing in my UpdateGeometry() to make this work? If a different physics list is used, with NO HP neutron physics included, there is NO segmentation fault. Thank you, Best regards, Cristian