| Summary: | Segmentation fault from GetCreatorProcess() | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Neoh Yuen Sim <neoh.ys> |
| Component: | event | Assignee: | asai |
| Status: | RESOLVED INVALID | ||
| Severity: | trivial | CC: | kelsey, kurasige |
| Priority: | P5 | ||
| Version: | 9.4 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
|
Description
Neoh Yuen Sim
2011-02-09 04:40:32 CET
(In reply to comment #0) > I got a segmentation fault when trying to output the creator process of some > particles. It turns out the particles are in fact generated by general particle > source. Some of them reach directly onto my detector without interaction. It > would be nice if g4 can safeguard the output of GetCreatorProcess(),in > particular when the particles detected are from particle gun itself. If the particle is not a secondary, then GetCreatorProcess() correctly returns a null pointer. The client code (i.e., your user action) is responsible for testing returned pointers for null before dereferencing them. See, for example, examples/advanced/composite_calorimeter/src/CCaloSD.cc. Note that, despite this injunction, several of the examples do not properly test the pointer before derefencing to get the process name. As Mike wrote, this is the way how this method behaves, and null-pointer protection is suggested in the user's code. See for example this HyperNews posting. http://hypernews.slac.stanford.edu/HyperNews/geant4/get/eventtrackmanage/919/1.html |