Problem 1834

Summary: Data race in decay sampling in MT mode
Product: Geant4 Reporter: Vladimir.Ivantchenko
Component: runAssignee: Andrea Dotti <andrea.dotti>
Status: RESOLVED FIXED    
Severity: major    
Priority: P5    
Version: 10.0   
Hardware: All   
OS: All   

Description Vladimir.Ivantchenko 2016-02-24 19:40:14 CET
CMS MT job analysis using helgrind for G4 10.0p03 identify a problem (which may be not resolved until now):

==32715== ----------------------------------------------------------------
==32715==
==32715== Possible data race during write of size 8 at 0x28938C38 by thread #6
==32715== Locks held: none
==32715==    at 0x231FD7D2: G4KL3DecayChannel::DecayIt(double) (in
/afs/cern.ch/cms/slc6_amd64_gcc493/cms/cmssw/CMSSW_8_0_0_pre4/biglib/slc6_amd64_gcc493/pluginSimulation.so)
==32715==    by 0x22C765FD: G4Decay::DecayIt(G4Track const&, G4Step const&) (in
/afs/cern.ch/cms/slc6_amd64_gcc493/cms/cmssw/CMSSW_8_0_0_pre4/biglib/slc6_amd64_gcc493/pluginSimulation.so)
==32715==    by 0x2330E6EA: G4SteppingManager::InvokeAtRestDoItProcs() (in
/afs/cern.ch/cms/slc6_amd64_gcc493/cms/cmssw/CMSSW_8_0_0_pre4/biglib/slc6_amd64_gcc493/pluginSimulation.so)
==32715==    by 0x2330CD2F: G4SteppingManager::Stepping() (in
/afs/cern.ch/cms/slc6_amd64_gcc493/cms/cmssw/CMSSW_8_0_0_pre4/biglib/slc6_amd64_gcc493/pluginSimulation.so)
==32715==    by 0x22F57233: G4TrackingManager::ProcessOneTrack(G4Track*) (in
/afs/cern.ch/cms/slc6_amd64_gcc493/cms/cmssw/CMSSW_8_0_0_pre4/biglib/slc6_amd64_gcc493/pluginSimulation.so)
==32715==    by 0x22C8DC01: G4EventManager::DoProcessing(G4Event*) (in
/afs/cern.ch/cms/slc6_amd64_gcc493/cms/cmssw/CMSSW_8_0_0_pre4/biglib/slc6_amd64_gcc493/pluginSimulation.so)
==32715==    by 0x22AD79F9: RunManagerMTWorker::produce(edm::Event const&, edm::EventSetup const&, RunManagerMT const&)
(in /afs/cern.ch/cms/slc6_amd64_gcc493/cms/cmssw/CMSSW_8_0_0_pre4/biglib/slc6_amd64_gcc493/pluginSimulation.so)

==32715==
==32715== This conflicts with a previous write of size 8 by thread #9
==32715== Locks held: none
==32715==    at 0x231FD7D2: G4KL3DecayChannel::DecayIt(double) (in
/afs/cern.ch/cms/slc6_amd64_gcc493/cms/cmssw/CMSSW_8_0_0_pre4/biglib/slc6_amd64_gcc493/pluginSimulation.so)
==32715==    by 0x22C765FD: G4Decay::DecayIt(G4Track const&, G4Step const&) (in
/afs/cern.ch/cms/slc6_amd64_gcc493/cms/cmssw/CMSSW_8_0_0_pre4/biglib/slc6_amd64_gcc493/pluginSimulation.so)
==32715==    by 0x2330E6EA: G4SteppingManager::InvokeAtRestDoItProcs() (in
/afs/cern.ch/cms/slc6_amd64_gcc493/cms/cmssw/CMSSW_8_0_0_pre4/biglib/slc6_amd64_gcc493/pluginSimulation.so)
==32715==    by 0x2330CD2F: G4SteppingManager::Stepping() (in
/afs/cern.ch/cms/slc6_amd64_gcc493/cms/cmssw/CMSSW_8_0_0_pre4/biglib/slc6_amd64_gcc493/pluginSimulation.so)
==32715==    by 0x22F57233: G4TrackingManager::ProcessOneTrack(G4Track*) (in
/afs/cern.ch/cms/slc6_amd64_gcc493/cms/cmssw/CMSSW_8_0_0_pre4/biglib/slc6_amd64_gcc493/pluginSimulation.so)
==
Comment 1 Andrea Dotti 2016-02-26 02:28:27 CET
To fix this issue we need a possible (small) redesign of G4VDecayChannel class. Starting with some investigations.
Comment 2 Andrea Dotti 2016-03-01 18:59:40 CET
Candidate fix tags have been proposed. There will be some work to be done to backport the fix to 10.{0,1,2}. We'll need to discuss about how to provide the patch because it requires an API change
Comment 3 Vladimir.Ivantchenko 2016-03-02 11:02:58 CET
Hi Andrea,

in my view, we may choose to do the full fix in patches to previous releases or not. Having some intermediate solution may be a problem.

Cheers,
Vladimir
Comment 4 Andrea Dotti 2016-06-27 17:28:43 CEST
Fixed in development line for 10.3 and in retroactive patch for 10.2, will not fix for versions < 10.2