Problem 858

Summary: Segmentation fault in G4NeutronHPFSFissionFS::ApplyYourself
Product: Geant4 Reporter: dale.prokopovich
Component: processes/hadronic/processesAssignee: tkoi
Status: RESOLVED FIXED    
Severity: major CC: iwan
Priority: P2    
Version: 7.1   
Hardware: Other   
OS: Linux   

Description dale.prokopovich 2006-04-09 22:32:44 CEST
We have uncovered a fault in the G4NeutronHPFSFissionFS::ApplyYourself method,
I have attached some debugging as follows (Thanks to Iwan for this):

$ gdb testSimFission

> run macros/run.mac

got the following output
********************************************************************************
*************************
* G4Track Information:   Particle = neutron,   Track ID = 141,   Parent ID =
138
********************************************************************************
*************************

Step#    X(mm)    Y(mm)    Z(mm) KinE(MeV)  dE(MeV) StepLeng TrackLeng
NextVolume ProcName
    0     -314     -746   -0.641       5.2        0        0         0
world initStep G4VDiscreteProcess::PostStepGetPhysicalInteractionLength [
LFission]  Particle type - neutron
   mass:        0.93956563[GeV]
   charge:      0[e]
   Direction x: 0.005674047684551061, y: 0.8745906531827237, z:
-0.4848288301537876
   Total Momentum = 0.09896205400344373[GeV]
   Momentum: 0.0005615154133766569[GeV], y: 0.08655128745117582[GeV], z:
-0.04797965687210557[GeV]
   Total Energy   = 0.9447629656214713[GeV]
   Kinetic Energy = 0.005197335621471327[GeV]
   ProperTime     = 0[ns]
 in Material  UraniumOxide
InteractionLength= 42.00220041220177[cm]
    1     -311     -379     -204         0        0      420       420
world LFission
    :----- List of 2ndaries - #SpawnInStep=  2(Rest= 0,Along= 0,Post= 2),
#SpawnTotal=  2 ---------------
    :      -311      -379      -204      1.56            neutron
    :      -311      -379      -204      4.49            neutron
    :-----------------------------------------------------------------
EndOf2ndaries Info ---------------

********************************************************************************
*************************
* G4Track Information:   Particle = neutron,   Track ID = 143,   Parent ID =
141
********************************************************************************
*************************

Step#    X(mm)    Y(mm)    Z(mm) KinE(MeV)  dE(MeV) StepLeng TrackLeng
NextVolume ProcName
    0     -311     -379     -204      4.49        0        0         0
world initStep



G4VDiscreteProcess::PostStepGetPhysicalInteractionLength [ LFission]  Particle
type - neutron
   mass:        0.93956563[GeV]
   charge:      0[e]
   Direction x: 0.5974698648571045, y: 0.6447015055422751, z:
0.4768539916359692
   Total Momentum = 0.09194779653187769[GeV]
   Momentum: 0.05493603756780951[GeV], y: 0.05927888285539634[GeV], z:
0.04384567379835781[GeV]
   Total Energy   = 0.9440540081819284[GeV]
   Kinetic Energy = 0.004488378181928371[GeV]
   ProperTime     = 0[ns]
 in Material  UraniumOxide
InteractionLength= 28.9176561471371[cm]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1080975904 (LWP 11832)]
0x080eede5 in G4NeutronHPFSFissionFS::ApplyYourself ()

*****then run the backtrace command through GDB which gives****

(gdb) bt
#0  0x080eede5 in G4NeutronHPFSFissionFS::ApplyYourself ()
#1  0x08114061 in G4NeutronHPFissionFS::ApplyYourself ()
#2  0x0810b505 in G4NeutronHPChannel::ApplyYourself ()
#3  0x080ea3e4 in G4NeutronHPFission::ApplyYourself ()
#4  0x0812510a in G4HadronicInteractionWrapper::ApplyInteraction
(this=0xbf835164, thePro=@0xbf835040, targetNucleus=@0x86c6f10,
theInteraction=0x86c84d0)
    at G4HadronicInteractionWrapper.cc:33
#5  0x08120cbc in G4HadronicProcess::GeneralPostStepDoIt ()
#6  0x081f49eb in G4SteppingManager::InvokePSDIP ()
#7  0x081f4c42 in G4SteppingManager::InvokePostStepDoItProcs () #8  0x081f59c8
in G4SteppingManager::Stepping () #9  0x081e96a6 in
G4TrackingManager::ProcessOneTrack () #10 0x081b90d1 in
G4EventManager::DoProcessing () #11 0x0819fcd2 in G4RunManager::DoEventLoop ()
#12 0x0819de2f in G4RunManager::BeamOn () #13 0x081a1d07 in
G4RunMessenger::SetNewValue () #14 0x08359a60 in G4UIcommand::DoIt () #15
0x08360e5e in G4UImanager::ApplyCommand () #16 0x0836bbbe in
G4UIbatch::SessionStart () #17 0x0835da94 in G4UImanager::ExecuteMacroFile ()
#18 0x0836cae5 in G4UIcontrolMessenger::SetNewValue () #19 0x08359a60 in
G4UIcommand::DoIt () #20 0x08360e5e in G4UImanager::ApplyCommand () #21
0x080500d0 in main ()
(gdb) quit

**** And then using some debugging code in the ApplyYourself Method gives...

 G4DynamicParticleVector * G4NeutronHPFSFissionFS::ApplyYourself(G4int
nPrompt,
                                                 G4int nDelayed, G4double *
theDecayConst)
  {
    G4int i;
    G4DynamicParticleVector * aResult = new G4DynamicParticleVector;
    G4ReactionProduct boosted;
    boosted.Lorentz(theNeutron, theTarget);
    G4double eKinetic = boosted.GetKineticEnergy();
    G4cout << "build neutrons" <<G4endl;
// Build neutrons
    G4ReactionProduct * theNeutrons = new G4ReactionProduct[nPrompt+nDelayed];
    for(i=0; i<nPrompt+nDelayed; i++)
    {
      theNeutrons[i].SetDefinition(G4Neutron::Neutron());
    }

    G4cout << "sample energies" <<G4endl;
// sample energies
   G4int it, dummy;
   G4double tempE;
   for(i=0; i<nPrompt; i++)
   {
     tempE = thePromptNeutronEnDis.Sample(eKinetic, dummy); // energy
distribution (file5) always in lab
     theNeutrons[i].SetKineticEnergy(tempE);
   }
   for(i=nPrompt; i<nPrompt+nDelayed; i++)
   {
     theNeutrons[i].SetKineticEnergy(theDelayedNeutronEnDis.Sample(eKinetic,
it));  // dito
     if(it==0)
theNeutrons[i].SetKineticEnergy(thePromptNeutronEnDis.Sample(eKinetic,
dummy));
     theDecayConst[i-nPrompt] = theFinalStateNeutrons.GetDecayConstant(it); //
this is returned
   }

    G4cout << "sample angles" <<G4endl;
// sample neutron angular distribution
   for(i=0; i<nPrompt+nDelayed; i++)
   {
     theNeutronAngularDis.SampleAndUpdate(theNeutrons[i]); // angular comes
back in lab automatically
   }

   G4cout << "add " << nPrompt+nDelayed << " to vector" <<G4endl; // already in
lab. Add neutrons to dynamic particle vector
   for(i=0; i<nPrompt+nDelayed; i++)
   {
       G4cout << "i " << i <<G4endl;
      G4DynamicParticle * it = new G4DynamicParticle;
       G4cout << "duynamic declare"<<G4endl;
      it->SetDefinition(theNeutrons[i].GetDefinition());
       G4cout << "definition set" <<G4endl;
      it->SetMomentum(theNeutrons[i].GetMomentum());
       G4cout << "momentum set "<<G4endl;
      aResult->push_back(it);
       G4cout << "pushed back" <<G4endl;
   }
    G4cout << "clean up" <<G4endl;
   delete [] theNeutrons;
// return the result
   return aResult;
  }


//////// this is the message before it seg faults.

build neutrons
sample energies
sample angles
add 4 to vector
i 0
duynamic declare
definition set
momentum set
pushed back
i 1
duynamic declare
definition set
momentum set
pushed back
i 2
duynamic declare
definition set
momentum set
pushed back
i 3

so apparently it seg faults at this point in the final loop above

 G4DynamicParticle * it = new G4DynamicParticle;

Any help with this problem would be great. A test simulation to reproduce the
error will be made available if required.

Regards,
Dale.
Comment 1 tkoi 2006-07-24 11:39:59 CEST
Hi,
I have update several part releated to Neutron HP Fission.
Please try Geant4 v8.1 and let me know trouble will disappere or not.
FYI only U data is available in G4NDL3.9 for fission reaction.

Tatsumi