opengate icon indicating copy to clipboard operation
opengate copied to clipboard

Segmentation faults when setting attributes of DigitizerHitsCollectionActor

Open acoussat opened this issue 1 year ago • 6 comments

Hi!

I noticed a behavior that seems strange: I get a segmentation violation whenever I try to set the attributes on a DigitizerHitsCollectionActor. For instance, when I try to run test 025, the lines

hc.attributes = [
        "TotalEnergyDeposit",
        "KineticEnergy",
        "PostPosition",
        "TrackCreatorProcess",
        "GlobalTime",
        "TrackVolumeName",
        "RunID",
        "ThreadID",
        "TrackID",
    ]

yield a segmentation fault. The problem disappears when commenting out the lines (but of course the test fails later on). Any idea of what is going on and how to overcome the problem?

acoussat avatar Apr 28 '23 07:04 acoussat

Hi, test025 runs fine for me. Can you please check your compilation/version ? If you still had troubles, we can zoom to discuss

dsarrut avatar Apr 28 '23 10:04 dsarrut

Hi,

Thank you for your answer. I have recompiled everything but still get the error. I must most probably do something wrong during compilation, but I have no idea what that might be. I have followed the steps described in the documentation. Any idea of what I could check?

acoussat avatar May 29 '23 14:05 acoussat

At which point does the segfault occur? While the simulation is initialized? During the run? At the end? Can you paste the trace back of the segfault? And what kind of message do you get with the segfault? E.g. "address not mapped to object" or something similar?

nkrah avatar Jun 15 '23 15:06 nkrah

From what I understand, it crashes while the simulation is initialized (that is when the Python script is being executed, before the sim.start()).

Please find attached the output of opengate_tests -i 25:

Look for tests in: /home/aurelien/Software/dev/gate/opengate/opengate/tests/../tests/src
Ignoring: test038_gan_phsp_spect_gan_ze.py         (Torch is not available) 
Ignoring: test043_garf.py                          (Torch is not available) 
Ignoring: test040_gan_phsp_pet_gan.py              (Torch is not available) 
Ignoring: test038_gan_phsp_spect_gan_aa.py         (Torch is not available) 
Ignoring: test034_gan_phsp_linac.py                (Torch is not available) 
Ignoring: test047_gan_vox_source_cond.py           (Torch is not available) 
Ignoring: test021_voxel_source_old_WIP.py          (Work In Progress) 
Ignoring: test038_gan_phsp_spect_gan_se.py         (Torch is not available) 
Ignoring: test039_hits_memory_check_MP_WIP.py      (Work In Progress) 
Ignoring: test024_py_actor_WIP.py                  (Work In Progress) 
Ignoring: test038_gan_phsp_spect_gan_MT.py         (Torch is not available) 
Ignoring: test045_speedup_all.py                   (Torch is not available) 
Ignoring: test013_phys_lists_3_WIP.py              (Work In Progress) 
Ignoring: test018_pet_WIP.py                       (Work In Progress) 
Ignoring: test001_G4ThreeVector.py                 (< 25) 
Ignoring: test002_G4String.py                      (< 25) 
Ignoring: test003_G4Material.py                    (< 25) 
Ignoring: test004_simple.py                        (< 25) 
Ignoring: test004_simple_MT.py                     (< 25) 
Ignoring: test004_simulation_stats_actor.py        (< 25) 
Ignoring: test005_proton.py                        (< 25) 
Ignoring: test006_runs.py                          (< 25) 
Ignoring: test007_volumes.py                       (< 25) 
Ignoring: test008_dose_actor.py                    (< 25) 
Ignoring: test008_geometry_dose_grid.py            (< 25) 
Ignoring: test009_voxels.py                        (< 25) 
Ignoring: test009_voxels_hu.py                     (< 25) 
Ignoring: test010_generic_source.py                (< 25) 
Ignoring: test010_generic_source_confine.py        (< 25) 
Ignoring: test011_MT.py                            (< 25) 
Ignoring: test012_MT_dose_actor.py                 (< 25) 
Ignoring: test013_half_life.py                     (< 25) 
Ignoring: test013_phys_lists_1.py                  (< 25) 
Ignoring: test013_phys_lists_2.py                  (< 25) 
Ignoring: test013_phys_lists_4.py                  (< 25) 
Ignoring: test013_phys_lists_5.py                  (< 25) 
Ignoring: test014_engine_1.py                      (< 25) 
Ignoring: test014_engine_2.py                      (< 25) 
Ignoring: test014_engine_3.py                      (< 25) 
Ignoring: test014_engine_4.py                      (< 25) 
Ignoring: test015_iec_phantom_1.py                 (< 25) 
Ignoring: test015_iec_phantom_2.py                 (< 25) 
Ignoring: test015_iec_phantom_3.py                 (< 25) 
Ignoring: test015_iec_phantom_4.py                 (< 25) 
Ignoring: test016_bool_volumes.py                  (< 25) 
Ignoring: test017_repeater.py                      (< 25) 
Ignoring: test019_linac_phsp.py                    (< 25) 
Ignoring: test019_linac_phsp_MT.py                 (< 25) 
Ignoring: test020_profiling.py                     (< 25) 
Ignoring: test021_voxel_source1.py                 (< 25) 
Ignoring: test021_voxel_source2.py                 (< 25) 
Ignoring: test022_half_life.py                     (< 25) 
Ignoring: test022_half_life_MT.py                  (< 25) 
Ignoring: test023_filters.py                       (< 25) 
Ignoring: test023_filters_iec_phantom.py           (< 25) 
Ignoring: test023_filters_material.py              (< 25) 
Running 55 tests
----------------------------------------------------------------------

### CAUGHT SIGNAL: 11 ### address: 0x28,  signal =  SIGSEGV, value =   11, description = segmentation violation. Address not mapped to object.

Backtrace:
[PID=23092, TID=-1][ 0/26]> /home/aurelien/Software/dev/gate/geant4.11-build/BuildProducts/lib/libG4analysis.so(_ZNSt6vectorINSt10filesystem7__cxx114path5_CmptESaIS3_EED1Ev+0xb) [0x7f1515ac85eb]
[PID=23092, TID=-1][ 1/26]> /home/aurelien/Software/dev/gate/geant4.11-build/BuildProducts/lib/libG4analysis.so(_ZNSt10filesystem7__cxx114pathD2Ev+0x29) [0x7f1515ac8689]
[PID=23092, TID=-1][ 2/26]> /home/aurelien/Software/dev/gate/geant4.11-build/BuildProducts/lib/libG4analysis.so(_ZN10G4Analysis11GetBaseNameERK8G4String+0x32c) [0x7f1515c3a19c]
[PID=23092, TID=-1][ 3/26]> /home/aurelien/Software/dev/gate/geant4.11-build/BuildProducts/lib/libG4analysis.so(_ZNK17G4BaseFileManager15GetFullFileNameERK8G4Stringb+0x7c) [0x7f1515c36a6c]
[PID=23092, TID=-1][ 4/26]> /home/aurelien/Software/dev/gate/geant4.11-build/BuildProducts/lib/libG4analysis.so(_ZN17G4RootFileManager8OpenFileERK8G4String+0x6b) [0x7f1515c9e54b]
[PID=23092, TID=-1][ 5/26]> /home/aurelien/Software/dev/gate/geant4.11-build/BuildProducts/lib/libG4analysis.so(_ZN21G4RootAnalysisManager12OpenFileImplERK8G4String+0x9b) [0x7f1515c8f80b]
[PID=23092, TID=-1][ 6/26]> /home/aurelien/Software/dev/gate/geant4.11-build/BuildProducts/lib/libG4analysis.so(_ZN18G4VAnalysisManager8OpenFileERK8G4String+0x42) [0x7f1515c898f2]
[PID=23092, TID=-1][ 7/26]> /home/aurelien/Software/dev/gate/opengate/core/opengate_core/opengate_core.cpython-311-x86_64-linux-gnu.so(+0x118ac9) [0x7f1514003ac9]
[PID=23092, TID=-1][ 8/26]> /home/aurelien/Software/dev/gate/opengate/core/opengate_core/opengate_core.cpython-311-x86_64-linux-gnu.so(+0x11ed66) [0x7f1514009d66]
[PID=23092, TID=-1][ 9/26]> /home/aurelien/Software/dev/gate/opengate/core/opengate_core/opengate_core.cpython-311-x86_64-linux-gnu.so(+0xc6e74) [0x7f1513fb1e74]
[PID=23092, TID=-1][10/26]> /home/aurelien/Software/dev/gate/opengate/core/opengate_core/opengate_core.cpython-311-x86_64-linux-gnu.so(+0x1e8145) [0x7f15140d3145]
[PID=23092, TID=-1][11/26]> python() [0x525877]
[PID=23092, TID=-1][12/26]> python(PyObject_Call+0x20c) [0x53f22c]
[PID=23092, TID=-1][13/26]> python(_PyObject_MakeTpCall+0x254) [0x502734]
[PID=23092, TID=-1][14/26]> python(_PyEval_EvalFrameDefault+0x758) [0x50eaa8]
[PID=23092, TID=-1][15/26]> python() [0x5c859e]
[PID=23092, TID=-1][16/26]> python(PyEval_EvalCode+0x9f) [0x5c7c9f]
[PID=23092, TID=-1][17/26]> python() [0x5e8857]
[PID=23092, TID=-1][18/26]> python() [0x5e4e90]
[PID=23092, TID=-1][19/26]> python() [0x5f90e2]
[PID=23092, TID=-1][20/26]> python(_PyRun_SimpleFileObject+0x19f) [0x5f86cf]
[PID=23092, TID=-1][21/26]> python(_PyRun_AnyFileObject+0x43) [0x5f8423]
[PID=23092, TID=-1][22/26]> python(Py_RunMain+0x2ee) [0x5f2f9e]
[PID=23092, TID=-1][23/26]> python(Py_BytesMain+0x39) [0x5b70d9]
[PID=23092, TID=-1][24/26]> /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f1515ede083]
[PID=23092, TID=-1][25/26]> python() [0x5b6f23]

: Segmentation fault (Address not mapped to object [0x28])
Aborted (core dumped)
['Direction', 'EventDirection', 'EventID', 'EventKineticEnergy', 'EventPosition', 'GlobalTime', 'HitUniqueVolumeID', 'KineticEnergy', 'LocalTime', 'ParentID', 'ParticleName', 'Position', 'PostDirection', 'PostKineticEnergy', 'PostPosition', 'PostStepUniqueVolumeID', 'PostStepVolumeCopyNo', 'PreDirection', 'PreDirectionLocal', 'PreKineticEnergy', 'PrePosition', 'PreStepUniqueVolumeID', 'PreStepVolumeCopyNo', 'ProcessDefinedStep', 'RunID', 'ThreadID', 'TimeFromBeginOfEvent', 'TotalEnergyDeposit', 'TrackCreatorProcess', 'TrackID', 'TrackProperTime', 'TrackVertexKineticEnergy', 'TrackVertexMomentumDirection', 'TrackVertexPosition', 'TrackVolumeCopyNo', 'TrackVolumeInstanceID', 'TrackVolumeName', 'Weight']
List of active attributes (including dynamic attributes) ['TotalEnergyDeposit', 'KineticEnergy', 'PostPosition', 'TrackCreatorProcess', 'GlobalTime', 'TrackVolumeName', 'RunID', 'ThreadID', 'TrackID']
Simulation: create RunManager


          ################################
          !!! G4Backtrace is activated !!!
          ################################

Simulation: initialize Geometry
Simulation: initialize Physics
Simulation: initialize Source
Simulation: initialize Actions
Simulation: initialize G4RunManager
Simulation: initialize Physics cuts
Simulation: initialize Actors
Simulation: (no volumes overlap checking)
--------------------------------------------------------------------------------
Simulation: START 
Running: test025_hits_collection.py                       FAILED !   2.4 s     /home/aurelien/Software/dev/gate/opengate/opengate/tests/../tests/log/test025_hits_collection.py.log

[…continues to test 26 and so on…]

So, to answer your question, yes I get the message Address not mapped to object.

acoussat avatar Jul 13 '23 13:07 acoussat

Sorry for not getting back to you earlier. Not sure if this is still an issue for you. If so, please change ui.g4_verbose = False into ui.g4_verbose = True in test025_hits_collection_helpers.py

and comment the line t025.test_simulation_results(sim.output) in test025_hits_collection.py.

Then run test025_hits_collection.py individually and paste the output. Thanks. That might help pin point the problem.

From the output you previously pasted, I have the impression that there is some problem with Geant4 and Root on your system. Maybe G4 cannot write the root file? Maybe the path does not exist....

As with @dsarrut, I cannot reproduce the error on my machine.

nkrah avatar Aug 07 '23 16:08 nkrah

@acoussat : This issue is quite old now. Is it still relevant?

nkrah avatar Nov 17 '23 09:11 nkrah