Problem 2354 - segmentation fault caused when processes are disabled via the user interface.
Summary: segmentation fault caused when processes are disabled via the user interface.
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: processes/electromagnetic/xrays (show other problems)
Version: 10.7
Hardware: PC Linux
: P4 normal
Assignee: Vladimir.Ivantchenko
URL:
Depends on:
Blocks:
 
Reported: 2021-04-01 01:26 CEST by Hans Wenzel
Modified: 2022-11-02 13:20 CET (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Hans Wenzel 2021-04-01 01:26:42 CEST
A segmentation fault is caused when processes are disabled  via the user interface. In this cas I am using the  FTFP_BERT reference physics list and the optical physics. But it doesn't matter what reference physics list is used. 

( ./G4OpticksTest -gdml G4Opticks_50000.gdml -pl 'FTFP_BERT+OPTICAL'  -macro muon_IO.mac)
 
So program run fine with 
/process/inactivate Scintillation

but 

/process/inactivate Scintillation

will cause a crash. 
Below is the backtrace running with a debugger

Using Root
Opening Analysis output File: histograms.root
... create file : histograms.root - done
... open analysis file : histograms.root - done

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : Tracking0013
      issued by : G4SteppingManager::InvokeAtRestDoItProcs()
No AtRestDoIt process is active!
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------


Program received signal SIGSEGV, Segmentation fault.
G4SteppingManager::InvokeAtRestDoItProcs (this=0x5555555e4260) at /data2/wenzel/geant4.10.07.p01/source/tracking/src/G4SteppingManager2.cc:329
329	      fParticleChange = fCurrentProcess->AtRestDoIt(*fTrack, *fStep);
(gdb) bt
#0  G4SteppingManager::InvokeAtRestDoItProcs (this=0x5555555e4260) at /data2/wenzel/geant4.10.07.p01/source/tracking/src/G4SteppingManager2.cc:329
#1  0x00007ffff5ed7467 in G4SteppingManager::Stepping (this=0x5555555e4260) at /data2/wenzel/geant4.10.07.p01/source/tracking/src/G4SteppingManager.cc:171
#2  0x00007ffff5ee3629 in G4TrackingManager::ProcessOneTrack (this=0x55555590c450, apValueG4Track=0x555556cb1630) at /data2/wenzel/geant4.10.07.p01/source/tracking/src/G4TrackingManager.cc:138
#3  0x00007ffff5f74f4e in G4EventManager::DoProcessing (this=0x55555590edb0, anEvent=0x555556ca9c00) at /data2/wenzel/geant4.10.07.p01/source/event/src/G4EventManager.cc:173
#4  0x00007ffff5f7583c in G4EventManager::ProcessOneEvent (this=0x55555590edb0, anEvent=0x555556ca9c00) at /data2/wenzel/geant4.10.07.p01/source/event/src/G4EventManager.cc:335
#5  0x00007ffff60ab0ce in G4RunManager::ProcessOneEvent (this=0x55555590eb80, i_event=0) at /data2/wenzel/geant4.10.07.p01/source/run/src/G4RunManager.cc:510
#6  0x00007ffff60aaf3d in G4RunManager::DoEventLoop (this=0x55555590eb80, n_event=500, macroFile=0x0, n_select=-1) at /data2/wenzel/geant4.10.07.p01/source/run/src/G4RunManager.cc:471
#7  0x00007ffff60aa675 in G4RunManager::BeamOn (this=0x55555590eb80, n_event=500, macroFile=0x0, n_select=-1) at /data2/wenzel/geant4.10.07.p01/source/run/src/G4RunManager.cc:343
#8  0x00007ffff60c6a7c in G4RunMessenger::SetNewValue (this=0x55555593ec40, command=0x55555593f0e0, newValue=...) at /data2/wenzel/geant4.10.07.p01/source/run/src/G4RunMessenger.cc:460
#9  0x00007ffff1d42c5f in G4UIcommand::DoIt (this=0x55555593f0e0, parameterList=...) at /data2/wenzel/geant4.10.07.p01/source/intercoms/src/G4UIcommand.cc:262
#10 0x00007ffff1d5a2e7 in G4UImanager::ApplyCommand (this=0x555555701b90, aCmd=0x55555620da00 "/run/beamOn 500") at /data2/wenzel/geant4.10.07.p01/source/intercoms/src/G4UImanager.cc:584
#11 0x00007ffff1d599fe in G4UImanager::ApplyCommand (this=0x555555701b90, aCmd=...) at /data2/wenzel/geant4.10.07.p01/source/intercoms/src/G4UImanager.cc:481
#12 0x00007ffff1d3d45e in G4UIbatch::ExecCommand (this=0x555555aa7080, command=...) at /data2/wenzel/geant4.10.07.p01/source/intercoms/src/G4UIbatch.cc:182
#13 0x00007ffff1d3d6b0 in G4UIbatch::SessionStart (this=0x555555aa7080) at /data2/wenzel/geant4.10.07.p01/source/intercoms/src/G4UIbatch.cc:230
#14 0x00007ffff1d5846e in G4UImanager::ExecuteMacroFile (this=0x555555701b90, fileName=0x7fffffffc790 "muon_IO.mac") at /data2/wenzel/geant4.10.07.p01/source/intercoms/src/G4UImanager.cc:308
#15 0x00007ffff1d53e2b in G4UIcontrolMessenger::SetNewValue (this=0x555555701fb0, command=0x5555557026f0, newValue=...) at /data2/wenzel/geant4.10.07.p01/source/intercoms/src/G4UIcontrolMessenger.cc:418
#16 0x00007ffff1d42c5f in G4UIcommand::DoIt (this=0x5555557026f0, parameterList=...) at /data2/wenzel/geant4.10.07.p01/source/intercoms/src/G4UIcommand.cc:262
#17 0x00007ffff1d5a2e7 in G4UImanager::ApplyCommand (this=0x555555701b90, aCmd=0x555555aa6ed0 "/control/execute muon_IO.mac") at /data2/wenzel/geant4.10.07.p01/source/intercoms/src/G4UImanager.cc:584
#18 0x00007ffff1d599fe in G4UImanager::ApplyCommand (this=0x555555701b90, aCmd=...) at /data2/wenzel/geant4.10.07.p01/source/intercoms/src/G4UImanager.cc:481
#19 0x0000555555569454 in main (argc=7, argv=0x7fffffffd0b8) at /data2/wenzel/gputest1_10.7.p01/G4OpticksTest/G4OpticksTest.cc:110
Comment 1 Vladimir.Ivantchenko 2021-04-13 16:31:22 CEST
Hello Hans,

from my point of view "disable" operation can work properly only for discrete processes. For all others there may be various problems.

I see two fully consistent solutions: 
  1) you make your own OpticalPhysics constructor
  2) we introduce flag into central G4OpticalPhysics constructor and UI messenger, which will enable/disable such process.

Vladimir
Comment 2 Vladimir.Ivantchenko 2021-04-13 16:45:24 CEST
To say more: formally general interface allowing disable processes but in practice we cannot, for example, remove ionisation in this way. So, I would not trying to fix your problem.
Comment 3 Hans Wenzel 2021-04-13 16:59:37 CEST
Hi 

thanks Vladimir for looking into it. My proposal would be to remove the messenger methods that seem to allow users to inactivate a process. 
It's kind of enoying that changing a setting allowed by the user interface then cause your program to crash. 

cheers Hans
Comment 4 Daren Sawkey 2021-05-11 00:14:57 CEST
Hi Hans,

There also exists the command 
/process/optical/processActivation Scintillation false
that should do the same thing. Do you see the crash with this? The command is only available in PreInit state.
Comment 5 Hans Wenzel 2021-05-11 17:40:48 CEST
Hi Daren 


It looks like switching off the process with the command you propose seems to work just fine. Just ran my test application with the macro included below. 


thanks 


Hans 







CaTS/enable_verbose false
/process/optical/processActivation Scintillation false
/run/initialize 

#
# the scintillation process is needed even when we run on GPU but we don't put optical photons on the stack
#
#/process/activate Scintillation
#/process/optical/scintillation/setStackPhotons false
#
# the Cerenkov process is needed even when we run on GPU but we don't put optical photons on the stack
#
/process/activate  Cerenkov 
/process/optical/cerenkov/setStackPhotons false
/process/optical/rayleigh/verbose 0
/process/optical/absorption/verbose 0
/process/optical/boundary/verbose 0
/random/setSeeds 7 38 
/CaTS/enable_opticks true
/CaTS/writeHits false
/CaTS/doAnalysis false
/gun/particle e-
/gun/energy 2 GeV
/gun/position 0. 0. -105. cm
/gun/direction 0. 0. 1.
/run/beamOn 100
Comment 6 Vladimir.Ivantchenko 2022-11-02 13:20:45 CET
Hello,

for Geant4 11.1 the problem is fixed - now AtRest processes may be deactivated.
Unfortunately, this fix would not be back-ported to previous releases.

VI