GRIFFINCollaboration / detectorSimulations_v10

Geant4 version 10 of the simulation code for the GRIFFIN array and it's suite of ancillary detection systems.
MIT License
9 stars 14 forks source link

Segmentation fault when running using macro #67

Closed DrDaveyAtoms closed 2 years ago

DrDaveyAtoms commented 4 years ago

Hi, I am experiencing a problem when running the Griffin Geant4 codes. Specifically, I am getting a segmentation fault when I execute a calculation using either the batch or interactive methods. I am attaching the output I receive in the terminal in case this helps to identify the problem.

Griffin_terminal_output_seg_fault_interactive.txt Griffin_terminal_output_seg_fault_batch.txt

I don't have a problem running any of my own simulations using similar vis.mac and run.mac files so I don't believe it is related to my installation of Geant4.

Any help or guidance you can provide would be most appreciated.

Thanks,

Dave

VinzenzBildstein commented 4 years ago

What does the run.mac look like? If this is the run.mac that is part of this repo, I noticed that it doesn't work for me either. Maybe we need to update it.

You can try using the macro in example_simulations/Co60_griffin_plus_full_structure/60Co.mac with the two lines with /grdm/... commented out (around line 89), and maybe the number of events changed to 10. I just checked and that one does run for me and produced output files with entries in them.

And if you want to debug the run.mac you are using, try running it through gdb: gdb --args Griffinv10 run.mac and then just say run in gdb and bt once it crashed.

DrDaveyAtoms commented 4 years ago

Thanks Vinzenz. I tried to run the code with the 60Co.mac file you suggested but I still obtain a seg fault. I then ran the code within the debugger and I obtain the following:

Griffin_terminal_output_seg_fault_GDB.txt

This is just the last 50 lines or so of the output to the terminal. To be honest, this doesn't help me to diagnose the problem but I hope it will help someone else.

VinzenzBildstein commented 4 years ago

One thing the backtrace tells me is that the crash happens at the very end, when the program stops. It crashes when calling the destructor of BeamDistribution (called from the destructor of PrimaryGeneratorAction). Now this destructor is empty, so I don't understand why it would crash here (though technically it crashes when destroying a vector member of that class).

Does it create any useful output files or does it crash before closing the root files?

DrDaveyAtoms commented 4 years ago

The simulation using 60Co.mac does generate a useful root file called g4out.root which seems to contain sensible data. I obtain a cobalt-60 gamma-ray spectrum in the depEnergy branch despite the seg fault.

VinzenzBildstein commented 4 years ago

Hmm, in that case I would think that the simulation works, though you might want to check what the event numbers are that are written to tree and if that matches the number of events you simulated. As long as everything gets written to the file (and not say everything but the last 1000 events), you should be good to use the simulation.

I also double checked and I can't reproduce the crash you see. What OS are you using and which compiler/Geant4 version do you have installed?