Geant4 crashes when loading gdml file (again)

(Accidentally deleted previous identical topic)

Geant4 Version: 11.3.0
Operating System: MacOS 14.0 (ARM64 M2 chip)
Compiler/Version: Apple clang version 15.0.0 (clang-1500.0.40.1)
CMake Version: 3.27.4


I’m having issues loading a gdml file into geant4. I am using a modified version of the ExampleB4a, where I edit the B4DetectorConstruction.cc file to add a gdml geometry with the following code snippet:

// Load GDML file
    G4GDMLParser parser;
    parser.Read("{my_sim_directory}/src/block.gdml", true); // false disables validation

    const G4LogicalVolumeStore* volumeStore = G4LogicalVolumeStore::GetInstance();
    for (const auto& volume : *volumeStore) {
            G4cout << "Found GDML volume: " << volume->GetName() << G4endl;
    }

Where I have the build, include, etc. directories in {my_sim_directory}. I want to load a more complicated gdml file terrain.gdml, but it gives a segmentation fault even with block.gdml, which I copied from the G01 example on loading .gdml files. The G01 example works for me, visualizing both the block.gdml and terrain.gdml files with Qt.

After making and running the exampleB4a executable, I get this output (the first lines are from the end of printing the material table)

   --->  Element: Magnesium (Mg)   Z = 12.0   N =    24   A = 24.305 g/mole
         --->  Isotope:  Mg24   Z = 12   N =  24   A =  23.99 g/mole   abundance: 78.990 %
         --->  Isotope:  Mg25   Z = 12   N =  25   A =  24.99 g/mole   abundance: 10.000 %
         --->  Isotope:  Mg26   Z = 12   N =  26   A =  25.98 g/mole   abundance: 11.010 %
          ElmMassFraction:   2.09 %  ElmAbundance   1.81 %



G4GDML: Reading '{my_sim_directory}/src/block.gdml'...

 *** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[/Users/odinschneider/osdir/geant4/geant4-v11.3.0/geant4-install/lib/libG4gdml.dylib] G4GDMLRead::Read(G4String const&, bool, bool, bool) (no debug info)
[{my_sim_directory}/build02/exampleB4a] B4DetectorConstruction::DefineVolumes() (no debug info)
[/Users/odinschneider/osdir/geant4/geant4-v11.3.0/geant4-install/lib/libG4run.dylib] G4RunManager::InitializeGeometry() (no debug info)
[/Users/odinschneider/osdir/geant4/geant4-v11.3.0/geant4-install/lib/libG4run.dylib] G4RunManager::Initialize() (no debug info)
[{my_sim_directory}/build02/exampleB4a] main (no debug info)
[/usr/lib/dyld] start (no debug info)

Since I used block.gdml, I don’t think this is an issue with the gdml file. Here is my B4DetectorConstruction.cc file. It is largely supposed to describe a burial site, where terrain.gdml would import the burial site and then a chamber is placed inside and a detector (camera) is put on the hill. I can’t attach the gdml files here due to their file format. If you could help me with this segmentation violation, that would be great. If more information is needed, please let me know :slight_smile:
B4DetectorConstruction.cc (21.3 KB)

update: I retried this with both geant4 versions 11.2.2 and 11.1.3 (instead of 11.3.0) and this lead to the same issue.

Have you looked at examples/extended/persistency/gdml? There might be some ways of doing things to be learnt there?

Sorry, see you have already looked.