Application hangs on G4TaskRunManager::CreateAndStartWorkers()

I have a simple application GitHub - jintonic/gears: Geant4 Example Application with Rich features and Small footprints. If I force it to run in serial mode (https://github.com/jintonic/gears/blob/master/gears.cc#L648), everything is fine. If I switch to MT mode using auto *run = G4RunManagerFactory::CreateRunManager() to run https://github.com/jintonic/gears/blob/master/tutorials/output/radiate.mac, the program hangs with the follow message. Since there is no further warming or error message, I don’t know where to look into the problem. Any suggestion is appreciated. Thanks, Jing

/run/beamOn 10

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : Run10035
      issued by : G4TaskRunManager::InitializeEventLoop()
Event modulo is reduced to 1 (was 3) to distribute events to all threads.
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------


-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : Run10035
      issued by : G4TaskRunManager::InitializeEventLoop()
Event modulo is reduced to 1 (was 3) to distribute events to all threads.
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

G4WT6 > /tracking/storeTrajectory 1
G4WT2 > /tracking/storeTrajectory 1
G4WT7 > /tracking/storeTrajectory 1
G4WT4 > /tracking/storeTrajectory 1
G4WT0 > /tracking/storeTrajectory 1
G4WT3 > /tracking/storeTrajectory 1
G4WT5 > /tracking/storeTrajectory 1
G4WT1 > /tracking/storeTrajectory 1

=========================================================================================
--> G4TaskRunManager::CreateAndStartWorkers() --> Creating 10 tasks with 1 events/task...
=========================================================================================

Can you run in gdb or lldb to track down what’s happening/where the hang might be occurring. You could also try increasing the verbosity of Run/Event (/run/verbose, /event/verbose UI commands) as a first step.

Hi, @bmorgan,

/event/verbose 2 helped me hunt down the problem. The program hangs on line https://github.com/jintonic/gears/blob/master/gears.cc#L552, where I use my output class’s Reset() function to reset all variables at the end of an event. My output class https://github.com/jintonic/gears/blob/master/gears.cc#L12 inherits G4SteppingVerbose and should be a singleton: https://github.com/jintonic/gears/blob/master/gears.cc#L647, but the output of /event/verbose 2+ my G4cout shows that

...
G4WT6 > output pointer: 0x11f6786a0
G4WT4 > NULL returned from G4StackManager.
G4WT4 > Terminate current event processing.
G4WT4 > output pointer: 0x1208e73c0
...

Multiple output class copies are created. I guess it makes sense to have one output class object for each thread. But I don’t know how a singleton works in multi-thread mode…

What kind of things I need to pay attention to to make my custom output functions thread-safe?

The other option here would be to use a concrete G4UserSteppingAction as that shouldn’t require any special treatment, though it depends on exactly what your use case for recording/etc steps is.

G4UserSteppingAction does not have access to step 0 information, while G4SteppingVerbose does. I’m happy to switch if the behavior of G4UserSteppingAction is modified in Geant4.

It might also be possible to use a tracking action, as its PreUserTrackingAction is called immediately after SetInitialStep (see G4TrackingManager::ProcessOneTrack for details of the ordering). At least, that gives access to the track immediately, though a separate SteppingAction would also be needed.

Alternately, see the extended/field/field01 example for one that implements a custom stepping verbose, and in particular the use of the F01ActionInitialization::InitializeSteppingVerbose class/member function. That should allow per-thread instances of a concrete steppingverbose to be created.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.