Simulation stuck in stepping action

I am using the default UserSteppingAction of geant4 and have a problem, where my simulation doesn’t manage to calculate the next step of my (chargedgeantino) particle.
Instead it gets stuck in the function “G4VoxelNavigation::ComputeStep” where the function “G4VoxelNavigation::LocateNextVoxel” is being called over and over again.
It seems like the local parameters, which this function “LocateNextVoxel” uses, repeat after a certain time.
So it is called with the same parameters again and keeps doing the same thing over and over but doesn’t get any further. How can I prevent this from happening?

_Geant4 Version:_11.1.2
_Operating System:_ubuntu 11.4.0-1ubuntu1 22.04
_Compiler/Version:_gcc c++ 11.4.0
_CMake Version:_3.22.1


Could you share your geometry and stepping action please?

Below I have a link to my repository (see branch SteppingActionBug) containing the geometry in the file spectroSim/src/DetectorConstructionScan.cc. It uses a json configuration file to set the dimensions.
In the configuration, where this problem occured, there are some overlaps of sensitive detectors with the magnets and of the magnets with each other. This is just a temporary state for a specific analysis I am doing right now and it will be changed later.
I initially thought these overlaps could be the cause. I ran the program with gdb and saw that it gets stuck in the loop in the G4VoxelNavigation::ComputeStep function after some time (always the same). Then the variable localPoint does not change anymore and the variables changed by the LocateNextVoxel function repeat after a few iterations of the loop in ComputeStep.
From these local parameters I could also see that the point, where it was trying to calculate the new step (localPoint), was nowhere near the overlaps. So to me, the overlaps do not seem to be the problem.
Concerning the stepping action: I do not have my own stepping action class, so the simulation should be using the standard G4UserSteppingAction.

If you want to reproduce the bug, you can also run the bash script ReproduceBug.sh, which builds the simulation and runs it right away in the configuration with the bug. I built the geant4 installation using the following cmake call (and make && make install):

cmake -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/home/laura/software/geant/geant4-v11.1.2-install-test \
    -DGEANT4_BUILD_MULTITHREADED=OFF \
    -DGEANT4_INSTALL_DATA=ON \
    -DGEANT4_USE_QT=ON \
    ../geant4-v11.1.2

link to my repository with the geometry: Files · SteppingActionBug · tamasigithub / compact_spectro · GitLab