Segmentation fault: 11 when executing example B1

After building example B1, these files appear in the build directory:

CMakeCache.txt		Makefile		exampleB1.in		init_vis.mac		run2.mac
CMakeFiles		cmake_install.cmake	exampleB1.out		run1.mac		vis.mac

Then I run

make -j2

and the the new files are

CMakeCache.txt cmake_install.cmake exampleB1.out run2.mac
CMakeFiles exampleB1 init_vis.mac vis.mac
Makefile exampleB1.in

According to the Installation Guide, everything is ready to run the example, but when I run

./exampleB1

I get the following text:

Available UI session types: [ GAG, tcsh, csh ]

-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : PART70000
issued by : G4NuclideTable
G4ENSDFSTATEDATA environment variable must be set
*** Fatal Exception *** core dump ***
Segmentation fault: 11

This is the second time I install Geant4 and try to build an example but the segmentation fault 11 keeps popping up. Any help is greatly appreciated.

Thanks!

Please see the Post-Install Setup Guide and especially the section on setting up env vars for the datasets.

Thanks for the reply! I followed the instructions for UNIX. First I did

. geant4.sh

But when running

source geant4.csh

the following thing happens:

-bash: /Users/Jp/Documents/Geant/geant4.10.06.p03-install/bin/geant4.csh: line 27: syntax error near unexpected token `(’

-bash: /Users/Jp/Documents/Geant/geant4.10.06.p03-install/bin/geant4.csh: line 27: `set ARGS=($_)’

I tried running this thing instead:

$ cd CMAKE_INSTALL_PREFIX/bin ; source geant4.csh

and

$ source CMAKE_INSTALL_PREFIX/bin/geant4.csh CMAKE_INSTALL_PREFIX/bin

but the result is the same. Any idea why this might be?

Thanks in advance.

You only need to run one of those commands to set up environment variables. Looks like you are using BASH so you only need to run the .sh file and not the .csh one.

Thanks for your reply. I know those commands do the same thing but I tried them all just in case the result was different. I only ran the .sh file as you suggested and then tried to run exampleB1 but the same thing is happening. I think it has to do with setting up the variables for the datasets as suggested by bmorgan, but I’m not sure how that is done in macOS.

I’ve not installed on macOS before so am going to assume it’s the same as linux.

Can you see that the variables are set for the datasets and that they are correct?

I get the following on my system

$ printenv | grep G4                                                                                                         
G4ENSDFSTATEDATA=/usr/local/share/geant4/data/G4ENSDFSTATE2.2                                                                           
G4PIIDATA=/usr/local/share/geant4/data/G4PII1.3                                                                                         
G4INCLDATA=/usr/local/share/geant4/data/G4INCL1.0                                                                                       
G4LEDATA=/usr/local/share/geant4/data/G4EMLOW7.7                                                                                        
G4PARTICLEXSDATA=/usr/local/share/geant4/data/G4PARTICLEXS1.1                                                                           
G4NEUTRONHPDATA=/usr/local/share/geant4/data/G4NDL4.5                                                                                   
G4SAIDXSDATA=/usr/local/share/geant4/data/G4SAIDDATA2.0                                                                                 
G4REALSURFACEDATA=/usr/local/share/geant4/data/RealSurface2.1.1                                                                         
G4ABLADATA=/usr/local/share/geant4/data/G4ABLA3.1                                                                                       
G4LEVELGAMMADATA=/usr/local/share/geant4/data/PhotonEvaporation5.3                                                                      
G4RADIOACTIVEDATA=/usr/local/share/geant4/data/RadioactiveDecay5.3      

No, I think this is exactly what I’m missing (setting up the variables and the datasets). The post-install page just puts the table with the variables and gives the steps for setting them up in Windows, but I’m not sure how to set them up in Linux. So my question would be, how did you set the variables for the datasets?

Thanks a lot for your help

I source the script in my ~/.bashrc file so they are set for every terminal, e.g.

. /full/path/to/install/dir/bin/geant4.sh

I thought this was mentioned in the install guide but it doesn’t seem to be.

Thanks for your reply. I am not very familiar with working in terminal so can you elaborate a little more on how to do that sourcing of script?

Thanks

The quoted line is exactly what you type, if you are using the Bash shell. The “.” is actually a special command in Bash, which also has the synonym “source” (I prefer using the latter myself). Then you give it the path to the setup script (geant4.sh) that you want to have sourced.

Sorry, I now understand what you both meant. I successfully ran the command

and there was no problem with that but running B1 still produces the same error. However, I think I understand what the problem is. As @php1ic suspected, the variables are not set for the data sets. I ran

and the variables are in different directories inside /full/path/to/install/dir/share, insted of /usr/local/share/. I’m guessing they need to be in the latter but want to ask before moving them. If that’s correct, should I manually move them there or is there a proper way to do this?

Thanks so much.

It appears that you ran your CMake build and installation without setting the CMake -DCMAKE_INSTALL_PREFIX=/my/desired/path/to/install/Geant4. The default installation area for CMake is /usr/local.

Therefore, when you source the setup script, presumably you are doing

. /usr/local/bin/geant4.sh

Is that correct? If so, it is setting the data directories to the values you quoted originally, under /usr/local/share

When you configured your Geant4 build, did you set -DGEANT4_INSTALL_DATA=OFF? If you did that, then you explicitly told the build to not download any of the datasets, so of course you don’t have them.

When you configured your Geant4 build, did you set -DGEANT4_INSTALL_DATADIR=/some/other/path/to/the/datasets? If you did that, then the datasets were installed in that other path. But of course, in that case the Geant4 env script should be consistent with that setting.

I followed the installation guide step by step, so I did

$ cmake -DCMAKE_INSTALL_PREFIX=/path/to/geant4.10.06-install

first, and later on the

$ cmake -DGEANT4_INSTALL_DATA=ON .

From what you are saying, maybe I shouldn’t have specified a directory in the -DCMAKE_INSTALL_PREFIX= to have everything installed to the default location /usr/local.

Actually, we’d recommend the opposite. Since G4 is such a huge installation, with so many parts (sources, examples, datasets, etc.), you are generally much better off putting it into a well-defined and separate installation directory tree. On my MacBook, for instance, I have /Applications/GEANT4/, with separate directories under it for each G4 version (all the way from 9.6 up to now!), and I have a directory /Applications/GEANT4/data/ for the datasets from all those releases together.

Ah, ha! I think that may be part of the problem. It sounds like you might have ended up with two separate installations, one under your /path/to/geant4.10.06-install, and one under /usr/local. You may need to do some manual cleaning up of things. I’d recommend in a cleaned out “build” directory, doing one single cmake command with all of the -D options on the same command line.

If you like, there’s also a terminal-based “GUI”, called ccmake, which you can run just giving the source directory path. It pops up a nice terminal menu listing all the possible option settings, and you can step through them with the arrow keys to set the ones you need. I find ccmake very helpful in discovering what settings G4 is using behind the scenes.

When I did

$ cmake -DCMAKE_INSTALL_PREFIX=/path/to/geant4.10.06-install

I actually set a separate directory for this. I have /Docuements/Geant4/and in Geant4 I have the 3 main directories (the source, build and install directories). I checked in /usr/local and there doesn’t seem to be a Geant4 installation there from what I could find (I checked the bin, include, lib and share directories and the files there are not the ones I see in the installation directory in /Docuements/Geant4/geant4.10.06.p03-install. Do you suggest reinstalling everything? I appreciate your quick responses but I’m uncertain on how to proceed. I still think my issue has to do with the post-install step of setting up the datasets and checking they are correct.

It may be that you would be better off wiping out what you’ve got and doing a clean build and install. In copying and installation of the datasets happens during the build/install process. That process also creates the “geant4.sh” (and .csh) scripts for you, based on the configuration. A clean, consistent build and install should end up with everything in appropriate directories, and with the env scripts pointing to those directories.