Segmentation violation while adding a logical volume to a region

Hello everyone!
I am trying to assign a logical volume to a region through AddRootLogicalVolume() in my DetectorConstruction.cc file:

G4Region* Region2 = new G4Region("Region2");
Region2->AddRootLogicalVolume(sensitive_logic);
sensitive_logic->SetRegion(Region2);

and it causes segmentation violation (once in a while, with a 50/50 chance):


 *** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[<unknown binary>] (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4geometry.dylib] G4Region::UpdateMaterialList() (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4geometry.dylib] G4RegionStore::UpdateMaterialList(G4VPhysicalVolume*) (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4run.dylib] G4RunManagerKernel::UpdateRegion() (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4run.dylib] G4RunManagerKernel::RunInitialization(bool) (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4run.dylib] G4RunManager::RunInitialization() (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4run.dylib] G4RunManager::BeamOn(int, char const*, int) (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4run.dylib] G4RunMessenger::SetNewValue(G4UIcommand*, G4String) (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4intercoms.dylib] G4UIcommand::DoIt(G4String) (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4intercoms.dylib] G4UImanager::ApplyCommand(char const*) (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4intercoms.dylib] G4UIbatch::ExecCommand(G4String const&) (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4intercoms.dylib] G4UIbatch::SessionStart() (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4intercoms.dylib] G4UImanager::ExecuteMacroFile(char const*) (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4intercoms.dylib] G4UIcontrolMessenger::SetNewValue(G4UIcommand*, G4String) (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4intercoms.dylib] G4UIcommand::DoIt(G4String) (no debug info)
[/usr/local/geant4/geant4.10.07.p01-build/BuildProducts/lib/libG4intercoms.dylib] G4UImanager::ApplyCommand(char const*) (no debug info)
[/Users/vasilysorokin/geant4_workdir/bin/Darwin-clang/bhamBeamline] main (no debug info)
[/usr/lib/system/libdyld.dylib] start (no debug info)

Any ideas why it may be happening? Tried to tweak it in many ways, but with no results, unfortunately…

Cheers,
Vasily

Hi,
I have the same type of issue, did you manage to solve it ?
cheers,
Maël

Hi Maël,
No, I gave up last year and found my way around without creating a region. What’s your Geant4 version?

Cheers,
Vasily

Hi !

I have been able to solve the problem by changing the name of the sensitive volume I wanted to add. This is not exactly the same situation as yours, my issue was coming from AddNewDetector() function. From what I’m seeing AddRootLogicalVolume work similarly, it check if a volume name already exist in store if so an error occur. I think the segmentation violation occurs when Geant4 try to locate where is a particle crossing a sensitive Geant4 Logical volume and see there is 2 with the same name. If you still want to solve your problem be sure that each logical volume you are using has a unique name.
Cheers,
Maël.

Hi Maël,
Many thanks for your detailed explanation, will try it out!

Vasily