Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move G4Event to TLS in RunManagerMTWorker #7303

Merged
merged 1 commit into from
Jan 21, 2015

Conversation

makortel
Copy link
Contributor

Fix the segfault in workflow 122.0 in THREADED build.

The segfault originates from the destruction of G4Event, which is a unique_ptr member of RunManagerMTWorker. It turns out that G4Event holds thread-local stuff, including effectively G4Allocator (via G4PrimaryParticle). In wf 122.0 it happens (usually) that G4Event (and the G4PrimaryPartifle-related G4Allocator) get

  • destructed in a different thread they were constructed, and
  • destructed twice in this thread.

In this case it is the dual-destruction that causes the segfault (G4Allocator being nullptr in the second destruction), but the first point needs to be fixed too.

A straightforward fix is to move G4Event to thread-local storage (among other thread-oriented stuff).

In addition to 122.0, tested with 2.0 in CMSSW_7_4_THREADED_X_2015-01-19-1400 giving identical results.

@civanch @Dr15Jones

G4Event holds thread-local stuff, of which one is G4Allocator. If
G4Event is a class member, it may happen that the G4Event (and thus
G4Allocator) get destructed in a different thread it was constructed.
Their destructors may even be executed twice in a thread resulting a
segfault. Moving G4Event to TLS fixes the issue.
@cmsbuild
Copy link
Contributor

A new Pull Request was created by @makortel (Matti Kortelainen) for CMSSW_7_4_X.

Move G4Event to TLS in RunManagerMTWorker

It involves the following packages:

SimG4Core/Application

@cmsbuild, @civanch, @nclopezo, @mdhildreth can you please review it and eventually sign? Thanks.
You can sign-off by replying to this message having '+1' in the first line of your reply.
You can reject by replying to this message having '-1' in the first line of your reply.
If you are a L2 or a release manager you can ask for tests by saying 'please test' in the first line of a comment.

@civanch
Copy link
Contributor

civanch commented Jan 21, 2015

+1
Fully agree with the fix but only concern to the comment: G4SimEvent is moved to TLS not G4Event

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next CMSSW_7_4_X IBs unless changes or unless it breaks tests.

@ghost
Copy link

ghost commented Jan 21, 2015

@cmsbuild please test

@makortel
Copy link
Contributor Author

In my commit I moved G4Event to TLS (G4SimEvent stays as a member of RunManagerMTWorker). Are you saying that G4SimEvent should be moved to TLS too?

@cmsbuild
Copy link
Contributor

The tests are being triggered in jenkins.

@civanch
Copy link
Contributor

civanch commented Jan 21, 2015

Sorry, comment was not precise due to the fact that the name of the class "G4SimEvent" is missleading. I think that the new variant, when G4Event is part of TLS and G4SimEvent - member of the WorkerMT, is fully correct.

@makortel
Copy link
Contributor Author

Ok, thanks for the clarification.

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next CMSSW_7_4_X IBs unless changes (tests are also fine). This pull request will be automatically merged.

cmsbuild added a commit that referenced this pull request Jan 21, 2015
Move G4Event to TLS in RunManagerMTWorker
@cmsbuild cmsbuild merged commit 680b597 into cms-sw:CMSSW_7_4_X Jan 21, 2015
@cmsbuild
Copy link
Contributor

@makortel makortel deleted the geant4mt_fix_G4Event branch October 20, 2016 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants