Project

General

Profile

Bug #1404

Seg. Faulting Simulation

Added by Lane, Peter over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Simulation
Target version:
Start date:
29 January 2014
Due date:
% Done:

100%

Estimated time:
Workflow:
New Issue

Description

The new Geant4 version appears to be seg faulting for some subset of beam configurations. I've stripped down one example that should reproduce this if my installation is kosher...

Stack trace:

===========================================================
#6 0x00007f81d21cbc1e in G4SteppingManager::InvokeAtRestDoItProcs() () from /home/lane/Development/maus/merge/third_party/install/lib64/libG4tracking.so
#7 0x00007f81d21c98b0 in G4SteppingManager::Stepping() () from /home/lane/Development/maus/merge/third_party/install/lib64/libG4tracking.so
#8 0x00007f81d21d1bec in G4TrackingManager::ProcessOneTrack(G4Track*) () from /home/lane/Development/maus/merge/third_party/install/lib64/libG4tracking.so
#9 0x00007f81d2febe7b in G4EventManager::DoProcessing(G4Event*) () from /home/lane/Development/maus/merge/third_party/install/lib64/libG4event.so
#10 0x00007f81d3908067 in G4RunManager::ProcessOneEvent(int) () from /home/lane/Development/maus/merge/third_party/install/lib64/libG4run.so
#11 0x00007f81d3907e75 in G4RunManager::DoEventLoop(int, char const*, int) () from /home/lane/Development/maus/merge/third_party/install/lib64/libG4run.so
#12 0x00007f81d3908a7c in G4RunManager::BeamOn(int, char const*, int) () from /home/lane/Development/maus/merge/third_party/install/lib64/libG4run.so
#13 0x00007f81cef7995b in MAUS::MAUSGeant4Manager::RunManyParticles (this=0x47d0250, particle_array=...) at src/common_cpp/Simulation/MAUSGeant4Manager.cc:115
#14 0x00007f81c907aacd in MAUS::MapCppSimulation::process (this=0x464bd50, document="{"mc_events": [{"primary": {"random_seed": 1872583848, "energy": 226.19392230000003, "particle_id": -13, "time": 0.0, "position": {"y": -0.18632574335497828, "x": -0.3214577360459491, "z": -4500.0}, ""...) at src/map/MapCppSimulation/MapCppSimulation.cc:66
#15 0x00007f81c90845c6 in _wrap_MapCppSimulation_process (args=0x46327a0) at src/map/MapCppSimulation/build/MapCppSimulation_wrap.cc:3299
#16 0x00007f81e45ee894 in ext_do_call (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:4323
#17 PyEval_EvalFrameEx (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:2705
#18 0x00007f81e45f043e in PyEval_EvalCodeEx (co=0x2d89ab0, globals=<value optimized out>, locals=<value optimized out>, args=<value optimized out>, argcount=2, kws=0x6b3ae00, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3253
#19 0x00007f81e45ee7fb in fast_function (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:4109
#20 call_function (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:4034
#21 PyEval_EvalFrameEx (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:2666
#22 0x00007f81e45ef0dd in fast_function (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:4099
#23 call_function (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:4034
#24 PyEval_EvalFrameEx (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:2666
#25 0x00007f81e45ef0dd in fast_function (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:4099
#26 call_function (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:4034
#27 PyEval_EvalFrameEx (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:2666
#28 0x00007f81e45ef0dd in fast_function (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:4099
#29 call_function (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:4034
#30 PyEval_EvalFrameEx (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:2666
#31 0x00007f81e45f043e in PyEval_EvalCodeEx (co=0x7f81e43757b0, globals=<value optimized out>, locals=<value optimized out>, args=<value optimized out>, argcount=6, kws=0x0, kwcount=0, defs=0x2d094e8, defcount=2, closure=0x0) at Python/ceval.c:3253
#32 0x00007f81e456faf1 in function_call (func=0x2d08d70, arg=0x46206d0, kw=0x0) at Objects/funcobject.c:526
#33 0x00007f81e4540e23 in PyObject_Call (func=0x2d08d70, arg=<value optimized out>, kw=<value optimized out>) at Objects/abstract.c:2529
#34 0x00007f81e45533ff in instancemethod_call (func=0x2d08d70, arg=0x46206d0, kw=0x0) at Objects/classobject.c:2578
#35 0x00007f81e4540e23 in PyObject_Call (func=0x3d8c9b0, arg=<value optimized out>, kw=<value optimized out>) at Objects/abstract.c:2529
#36 0x00007f81e45e8103 in PyEval_CallObjectWithKeywords (func=0x3d8c9b0, arg=0x4625950, kw=<value optimized out>) at Python/ceval.c:3882
#37 0x00007f81e4555256 in PyInstance_New (klass=<value optimized out>, arg=0x4625950, kw=0x0) at Objects/classobject.c:571
#38 0x00007f81e4540e23 in PyObject_Call (func=0x2cfca78, arg=<value optimized out>, kw=<value optimized out>) at Objects/abstract.c:2529
#39 0x00007f81e45eddea in do_call (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:4231
#40 call_function (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:4036
#41 PyEval_EvalFrameEx (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:2666
#42 0x00007f81e45ef0dd in fast_function (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:4099
#43 call_function (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:4034
#44 PyEval_EvalFrameEx (f=<value optimized out>, throwflag=<value optimized out>) at Python/ceval.c:2666
#45 0x00007f81e45f043e in PyEval_EvalCodeEx (co=0x7f81e43677b0, globals=<value optimized out>, locals=<value optimized out>, args=<value optimized out>, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3253
#46 0x00007f81e45f0552 in PyEval_EvalCode (co=<value optimized out>, globals=<value optimized out>, locals=<value optimized out>) at Python/ceval.c:667
#47 0x00007f81e4610080 in run_mod (fp=0x1e7b090, filename=<value optimized out>, start=<value optimized out>, globals=0x1dd9260, locals=0x1dd9260, closeit=1, flags=0x7fff21c28df0) at Python/pythonrun.c:1346
#48 PyRun_FileExFlags (fp=0x1e7b090, filename=<value optimized out>, start=<value optimized out>, globals=0x1dd9260, locals=0x1dd9260, closeit=1, flags=0x7fff21c28df0) at Python/pythonrun.c:1332
#49 0x00007f81e461024c in PyRun_SimpleFileExFlags (fp=0x1e7b090, filename=0x7fff21c29471 "/home/lane/Development/maus/analysis/bin/test_mice.py", closeit=1, flags=0x7fff21c28df0) at Python/pythonrun.c:936
#50 0x00007f81e4625704 in Py_Main (argc=<value optimized out>, argv=<value optimized out>) at Modules/main.c:599
#51 0x00000033ef21ed1d in __libc_start_main () from /lib64/libc.so.6
#52 0x0000000000400659 in _start () ===========================================================

Configuration file (test_config.py):

import os

simulation_geometry_filename = "./Stage2.dat" # geometry used by simulation
output_root_file_name = "simulation.root"
geant4_visualisation = True
accumulate_tracks = 1 # this accumulates the tracks into one vrml file 1 = yes, 0 = no
verbose_level=0
physics_processes = "mean_energy_loss"
particle_decay=False
maximum_number_of_steps = 20000

spill_generator_number_of_spills=1

simulation_reference_particle = { # used for setting particle phase # "position":{"x":0.0, "y":-0.0, "z":-14110.26},
"position":{"x":0.0, "y":-0.0, "z":-4500.},
"momentum":{"x":0.0, "y":0.0, "z":200.0},
"particle_id":-13, "energy":226.1939223, "time":0.0, "random_seed":10
}

beam = {
"random_seed":2,
"particle_generator":"counter", # routine for generating empty primaries
"definitions":[ ##### MUONS ####### {
"reference":simulation_reference_particle, # reference particle
"random_seed_algorithm":"incrementing_random", # algorithm for seeding MC
"n_particles_per_spill":10,
"weight":100., # probability of generating a particle
"transverse":{
"transverse_mode":"twiss",
"beta_x":100., # x betatron function (mm)
"alpha_x":1., # x emittance ellipse slope
"emittance_x":0.01, # RMS area (mm rad)
"beta_y":100., # y betatron function (mm)
"alpha_y":1., # y emittance ellipse slope
"emittance_y":0.01 # RMS area (mm rad)
},
"longitudinal":{
"longitudinal_mode":"pencil",
"momentum_variable":"p"},
"coupling":{"coupling_mode":"none"} # no dispersion
}]
}

Geometry (shifted along z by +1.09557 m from the official Stage2.dat):

Configuration Stage2 {
Dimensions 6. 6. 31. m
PropertyString Material AIR
PropertyDouble G4StepMax 1.0 mm
Module BeamLine/BeamLine.dat {
// Position 0. 0. -10.283 m
Position 0. 0. 672.74 mm
Rotation 0. 0. 0. degree
}
Module Tracker/TrackerSolenoid0.dat {
// Position 0. 0. -4.783 m
Position 0. 0. 6172.74 mm
Rotation 0. 0. 0. degree
}
Module TOF/TOF2.dat {
// Position 0. 0. -2.49 m
Position 0. 0. 8465.74 mm
Rotation 0. 0. 0. degree
}
}

Python launch script (test_mice.py):

import io # generic python library for I/O

import MAUS # MAUS libraries

def run():
""" Run the macro
"""

  1. This input generates empty spills, to be filled by the beam maker later on
    my_input = MAUS.InputPySpillGenerator()
  1. Create an empty array of mappers, then populate it
  2. with the functionality you want to use.
    my_map = MAUS.MapPyGroup()
  1. GEANT4
    my_map.append(MAUS.MapPyBeamMaker()) # beam construction
    my_map.append(MAUS.MapCppSimulation()) # geant4 simulation
  1. Then construct a MAUS output component - filename comes from datacards
    my_output = MAUS.OutputCppRoot()
  2. my_output = MAUS.OutputPyJSON()
  1. can specify datacards here or by using appropriate command line calls
    datacards = io.StringIO(u"")
  1. The Go() drives all the components you pass in, then check the file
  2. (default simulation.out) for output
    MAUS.Go(my_input, my_map, MAUS.ReducePyDoNothing(), my_output, datacards)

if name == '__main__':
run()

Invocation:

python ./test_mice.py --configuration_file ./test_config.py --verbose_level=0


Files

valgrind.log (332 KB) valgrind.log Rogers, Chris, 30 January 2014 07:52

Related issues

Related to MAUS - Bug #1470: Default half life not set correctlyClosedRogers, Chris20 May 2014

Actions
#1

Updated by Rogers, Chris over 9 years ago

Hmm, I tried running with this configuration and didn't see any issues. In particular, valgrind didn't give me any errors. valgrind log attached. I wonder if you can give me any help to nail the problem?

#2

Updated by Lane, Peter over 9 years ago

I don't know if it helps since there are no line numbers in the geant4 debug output, but valgrind gives me this:

===========================================

-------- WWWW ------- G4Exception-START -------- WWWW -------
  • G4Exception : Tracking0013
    issued by : G4SteppingManager::InvokeAtRestDoItProcs()
    No AtRestDoIt process is active!
  • This is just a warning message. ***
    -------- WWWW -------- G4Exception-END --------- WWWW -------
29392 Invalid read of size 8
29392 at 0x195F2C1E: G4SteppingManager::InvokeAtRestDoItProcs() (in /home/lane/Development/maus/merge/third_party/install/lib64/libG4tracking.so)
29392 by 0x195F08AF: G4SteppingManager::Stepping() (in /home/lane/Development/maus/merge/third_party/install/lib64/libG4tracking.so)
29392 by 0x195F8BEB: G4TrackingManager::ProcessOneTrack(G4Track*) (in /home/lane/Development/maus/merge/third_party/install/lib64/libG4tracking.so)
29392 by 0x187A7E7A: G4EventManager::DoProcessing(G4Event*) (in /home/lane/Development/maus/merge/third_party/install/lib64/libG4event.so)
29392 by 0x17EAF066: G4RunManager::ProcessOneEvent(int) (in /home/lane/Development/maus/merge/third_party/install/lib64/libG4run.so)
29392 by 0x17EAEE74: G4RunManager::DoEventLoop(int, char const*, int) (in /home/lane/Development/maus/merge/third_party/install/lib64/libG4run.so)
29392 by 0x17EAFA7B: G4RunManager::BeamOn(int, char const*, int) (in /home/lane/Development/maus/merge/third_party/install/lib64/libG4run.so)
29392 by 0x1C83295A: MAUS::MAUSGeant4Manager::RunManyParticles(Json::Value) (MAUSGeant4Manager.cc:115)
29392 by 0x23626ACC: MAUS::MapCppSimulation::process(std::string) (MapCppSimulation.cc:66)
29392 by 0x236305C5: _wrap_MapCppSimulation_process (MapCppSimulation_wrap.cc:3299)
29392 by 0x4D04893: PyEval_EvalFrameEx (ceval.c:4323)
29392 by 0x4D0643D: PyEval_EvalCodeEx (ceval.c:3253)
29392 Address 0x0 is not stack'd, malloc'd or (recently) free'd
29392

I'm attempting to simplify the geometry and configuration, but I'm not sure how much that will help as well since it is not failing universally.

#3

Updated by Lane, Peter over 9 years ago

Expanding out BeamLine.dat and removing bits gives me this reduced geometry that fails for me with the same configuration. Removing any of the modules causes the simulation to succeed.

Configuration Stage2 {
Dimensions 6. 6. 31. m
PropertyString Material AIR
PropertyDouble G4StepMax 1.0 mm
Module TOF/TOF0.dat {
Position 0. 0. -3465.05 mm
Rotation 0. 0. 0. degree
}
Module Ckov/Cherenkov.dat {
Position 0. 0. -2720.05 mm
Rotation 0. 0. 0. degree
}
Module BeamLine/QuadTypeQC_Boolean.dat {
Position 0. 0. +758.05 mm
Rotation 0. 0. 0. degree
ScaleFactor +1.293
}
Module BeamLine/QuadTypeQC_Boolean.dat {
Position 0. 0. +1918.05 mm
Rotation 0. 0. 0. degree
ScaleFactor -1.293
}
}

#4

Updated by Rogers, Chris over 9 years ago

Well, I guess AtRestProcsDoIt is calling some unallocated memory. I will have to dig to recall what AtRestProcs we have, maybe though this is because decays are turned off? Try turning decays on but setting half life to long time and see if that alleviates the segv?

#5

Updated by Rogers, Chris over 9 years ago

Try this:

http://hypernews.slac.stanford.edu/HyperNews/geant4/get/emprocess/249.html?inline=-1

I think the "set half life to long time" should fix the problem, at least for muons and pions. Let me know if the problem persists.

ps: I think that you only get debug output if you have debug flag switched on for the compiler - there is no way for valgrind to know line numbers as they are not in the binary file unless debug flag is switched on.

#6

Updated by Lane, Peter over 9 years ago

Thanks Chris, that seems to have done the trick.

#7

Updated by Rogers, Chris over 9 years ago

Okay, we should leave the tracker open - it is a segv on an advertised feature...

#8

Updated by Pidcott, Celeste over 9 years ago

Just to say that I've noticed the same problem when trying to simulate muons and pions in 0.8.0 with decays turned off; having simulation_geometry_filename as Stage4.dat and particle_decay set to False causes a segmentation violation.

#9

Updated by Rogers, Chris over 9 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Fixed in r707 - we now set the half life to a long time (max double/10.) instead of deactivating when the decays flag is false. That's the best I can do...

#10

Updated by Rajaram, Durga over 9 years ago

  • Target version changed from Future MAUS release to MAUS-v0.8.4

Also available in: Atom PDF