Problem 1218

Summary: Crash using RegularStructure with multiple BeamOn calls
Product: Geant4 Reporter: Derek Dolney <Derek.Dolney>
Component: runAssignee: asai
Status: RESOLVED FIXED    
Severity: critical CC: John.Apostolakis
Priority: P1    
Version: 9.4   
Hardware: All   
OS: All   

Description Derek Dolney 2011-05-31 03:48:06 CEST
I have simulation code that uses a G4PhantomParameterisation (hence, IsRegularStructure() == true) with a rotating modulator wheel (somewhat based off the one in the advanced/hadrontherapy example). The modulator wheel could rotate as many as 256 times in a given simulation run. Each time it is rotated, I call GeometryHasBeenModified(), followed by another BeamOn.

This code worked with 4.9.3 and older. With 4.9.4, my simulations terminate early with the following error:

---SNIP---------------------------------------------------------------

Beginning segment 93 of 156
Start of my run 94
 My event 0
ERROR - G4SteppingManager::GetProcessNumber()
        SizeOfSelectedDoItVector= 100 ; is smaller then one of MAXofAtRestLoops= 0
        or MAXofAlongStepLoops= 3 or MAXofPostStepLoops= 101

*** G4Exception : Tracking0012
      issued by : G4SteppingManager::GetProcessNumber()
The array size is smaller than the actual No of processes.
*** Fatal Exception *** core dump ***

*** G4Exception: Aborting execution ***

---SNIP---------------------------------------------------------------


Note that it is almost to segment 100, and apparently I have more than 100 processes with PostStep actions registered with the ProcessManager. Indeed, I traced this out and found that every call to G4RunManager::BeamOn() results in the following call stack: 

#0  G4RunManagerKernel::SetScoreSplitter (this=0xabf440)
    at src/G4RunManagerKernel.cc:556
#1  0x00007fffef9f1cf0 in G4RunManagerKernel::RunInitialization (this=0xabf440)
    at src/G4RunManagerKernel.cc:331
#2  0x00007fffef9f665d in G4RunManager::RunInitialization (this=0xabf6b0)
    at src/G4RunManager.cc:182
#3  0x00007fffef9f33d7 in G4RunManager::BeamOn (this=0xabf6b0, n_event=1, 
    macroFile=0x0, n_select=-1) at src/G4RunManager.cc:142

Note that in G4RunManagerKernel::SetScoreSplitter(), the G4ScoreSplittingProcess is added to the ProcessManager. So the general problem is, if a RegularStructure is used, and the user wants to call BeamOn multiple times, eventually a process vector fills up and the simulation is terminated.

Please help. I need other fixes that are in 4.9.4, but this issue is keeping me from upgrading.

Thank you in advance for your help.
Comment 1 John Apostolakis 2011-06-01 13:00:58 CEST
Thanks for the clear problem report.  Indeed there is a problem when the geometry is changed and such a type of regular voxel volume exists in the geometry.

From your clear report it was possible to create a simple protection for this, which was communicated to you privately.

This or an improved fix will be tested further and should be included in the next round of fixes.
Comment 2 Gabriele Cosmo 2011-07-19 09:09:57 CEST
Fix is now included in 9.4.p02.