From ebd84140c4d9428d2b51f474c32ae09c5019b993 Mon Sep 17 00:00:00 2001 From: Gonzalo Martinez Lema Date: Fri, 7 May 2021 12:08:39 +0300 Subject: [PATCH 1/2] Fix segfault in SaveAllSteppingAction When particles exit the world a nullptr causes segfault --- source/actions/SaveAllSteppingAction.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/actions/SaveAllSteppingAction.cc b/source/actions/SaveAllSteppingAction.cc index 9a7b8c26a8..d7474c0bb2 100644 --- a/source/actions/SaveAllSteppingAction.cc +++ b/source/actions/SaveAllSteppingAction.cc @@ -64,6 +64,8 @@ void SaveAllSteppingAction::UserSteppingAction(const G4Step* step) G4ThreeVector initial_pos = pre ->GetPosition(); G4ThreeVector final_pos = post->GetPosition(); + if (! post->GetTouchableHandle()->GetVolume()) return; // Particle exists the world + G4String initial_volume = pre ->GetTouchableHandle()->GetVolume()->GetName(); G4String final_volume = post->GetTouchableHandle()->GetVolume()->GetName(); G4String proc_name = post->GetProcessDefinedStep()->GetProcessName(); From bf27530bd0f50d70b589ac41e4f7c398cc64910a Mon Sep 17 00:00:00 2001 From: Gonzalo Martinez Lema Date: Fri, 25 Nov 2022 11:19:27 +0200 Subject: [PATCH 2/2] Fix typo --- source/actions/SaveAllSteppingAction.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/actions/SaveAllSteppingAction.cc b/source/actions/SaveAllSteppingAction.cc index d7474c0bb2..e25de80478 100644 --- a/source/actions/SaveAllSteppingAction.cc +++ b/source/actions/SaveAllSteppingAction.cc @@ -64,7 +64,7 @@ void SaveAllSteppingAction::UserSteppingAction(const G4Step* step) G4ThreeVector initial_pos = pre ->GetPosition(); G4ThreeVector final_pos = post->GetPosition(); - if (! post->GetTouchableHandle()->GetVolume()) return; // Particle exists the world + if (! post->GetTouchableHandle()->GetVolume()) return; // Particle exits the world G4String initial_volume = pre ->GetTouchableHandle()->GetVolume()->GetName(); G4String final_volume = post->GetTouchableHandle()->GetVolume()->GetName();