Problem 1603 - SIGSEGV when running B1 example
Summary: SIGSEGV when running B1 example
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: geometry (show other problems)
Version: 10.0
Hardware: Apple Mac OS X
: P5 normal
Assignee: Gabriele Cosmo
URL:
: 1619 1628 (view as problem list)
Depends on:
Blocks:
 
Reported: 2014-04-07 23:09 CEST by Jonas Nilsson
Modified: 2014-05-20 12:29 CEST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Jonas Nilsson 2014-04-07 23:09:18 CEST
I have compiled geant4-10-00-patch-01 [MT] on Mac OS X 10.9.2 using the following cmake command: cmake -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_QT=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DGEANT4_BUILD_MULTITHREADED=ON -DCMAKE_INSTALL_PREFIX=/usr/local ..

When running the macro file for basic example 1 ("./exampleB1 exampleB1.in"), Geant exits with the following output:
    ### Run 1 starts.
    G4WT0 > ### Run 1 starts on worker thread 0.
    G4WT1 > ### Run 1 starts on worker thread 1.
    G4WT0 > --> Event 0 starts with initial seeds (72908997,74216692).
    G4WT1 > --> Event 100 starts with initial seeds (74589296,41591767).
    fish: Job 1, './exampleB1 exampleB1.in' terminated by signal SIGSEGV (Address boundary error)

I have narrowed down the problem to the proton simulation part of the macro file. If I instead run Geant in interactive mode, I can usually perform a few proton simulations before it crashes.

Running the example using the lldb debugger, the application crashes with the following output:

    ### Run 1 starts.
    G4WT1 > ### Run 1 starts on worker thread 1.
    G4WT0 > ### Run 1 starts on worker thread 0.
    G4WT1 > --> Event 0 starts with initial seeds (72908997,74216692).
    G4WT1 > --> Event 100 starts with initial seeds (74589296,41591767).
    Process 3462 stopped
    * thread #2: tid = 0x16739, 0x0000000101adf89f libG4geometry.dylib`G4MagInt_Driver::AccurateAdvance(G4FieldTrack&, double, double, double) + 1375, stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
        frame #0: 0x0000000101adf89f libG4geometry.dylib`G4MagInt_Driver::AccurateAdvance(G4FieldTrack&, double, double, double) + 1375
    libG4geometry.dylib`G4MagInt_Driver::AccurateAdvance(G4FieldTrack&, double, double, double) + 1375:
    -> 0x101adf89f:  movaps (%rax), %xmm0
       0x101adf8a2:  movaps %xmm0, -0x590(%rbp)
       0x101adf8a9:  movaps 0x10(%rax), %xmm0
       0x101adf8ad:  movaps %xmm0, -0x580(%rbp)
Comment 1 Gabriele Cosmo 2014-04-08 10:00:15 CEST
You're likely using the latest version of clang distributed within the last upgrade of XCode, which obviously was not tested at the time 10.0.p01 was released...
A fix for the problem you observe has been already included in the development and will be part of the next patch.

Try to edit this file:
  source/geometry/magneticfield/include/G4FieldTrack.icc
and replace line 253 with:
  G4double valArr[ncompSVEC];

(i.e. remove "static G4ThreadLocal" in front).
Comment 2 Jonas Nilsson 2014-04-08 10:32:25 CEST
The fix you suggested solved the problem. Many thanks!
Comment 3 Gabriele Cosmo 2014-04-24 09:23:51 CEST
*** Problem 1619 has been marked as a duplicate of this problem. ***
Comment 4 Gabriele Cosmo 2014-05-20 12:29:11 CEST
*** Problem 1628 has been marked as a duplicate of this problem. ***