Segmentation fault scoring particle in volume


I’m trying to store the information of neutrons entering a certain volume of the lab. To be more specific: I’m firing muons, these muons produce neutrons that travel through the lab and reach a veto. So I’m trying to score their spectrum before entering this veto. I tried the methods described here and here So, this is what I tried:

  1. In the steppingAction:

    if(particle == “neutron”){
    G4VPhysicalVolume* volIn = step->GetPreStepPoint()->GetPhysicalVolume();
    G4VPhysicalVolume* volFin = step->GetPostStepPoint()->GetPhysicalVolume();
    G4bool condition = step->IsLastStepInVolume();

    if(volIn->GetName()==“Lab” && volFin->GetName()==“MuonVetoVolume”){
    if(condition) store info

  2. In steppingAction, use:

    G4bool condition = step->IsLastStepInVolume();
    if(particle == “neutron” && aStep->GetTrack()->GetVolume()->GetName()==“Lab” && aStep->GetTrack()->GetNextVolume()->GetName()==“MuonVetoVolume”){

    if(condition) store info

But I get the same segmentation fault:
#5 0x00007f88c8242f90 in std::__cxx11::basic_string<char, std::char_traits, std::allocator >::compare(char const*) const () from /usr/lib/x86_64-linux-gnu/
#6 0x00007f88d1e2c783 in G4String::operator== (this=0x18, str=0x7f88d1e919e6 “MuonVetoVolume”) at /home/jose/Codes/geant4.10.06/install/include/Geant4/G4String.icc:122

I run it again in verbose mode and I the last thing it does is:

G4Track Information: Particle = neutron, Track ID = 42836, Parent ID = 27784

Step# X(mm) Y(mm) Z(mm) KinE(MeV) dE(MeV) StepLeng TrackLeng NextVolume ProcName
0 -4.98e+04 -1.28e+04 -2.61e+04 0.134 0 0 0 Lab initStep
1 -6e+04 -1.55e+04 -2.42e+04 0.134 0 1.07e+04 1.07e+04 OutOfWorld Transportation

*** Break *** segmentation violation

When fire only neutrons from the Lab volume to the MuonVetoVolume both methods work, I checked it in the verbose mode. The problem is when I fire muons: some neutrons are stored correctly, but then one neutron of the above appear and produces a segmentation fault.

Where is my error? How could I solve it?
Thank you