Break Segmentation violation

The code compiled properly without any error. But, when i run the executable i get the following error:

` *** Break *** segmentation violation

There was a crash.
This is the entire stack trace of all threads:
#0  0x00007f5cb9ee7dbc in waitpid () from /usr/lib64/
#1  0x00007f5cb9e6acc2 in do_system () from /usr/lib64/
#2  0x00007f5cc5935ba9 in TUnixSystem::StackTrace() () from /scif/apps/root/lib/
#3  0x00007f5cc59378ac in TUnixSystem::DispatchSignals(ESignals) () from /scif/apps/root/lib/
#4  <signal handler called>
#5  0x00007f5cbba37ee2 in G4LogicalVolume::SetVisAttributes(G4VisAttributes const&) () from /scif/apps/geant4/lib64/
#6  0x00000000004124b7 in UCNBDetectorConstruction::Construct() ()
#7  0x00007f5cbedbb8c8 in G4RunManager::InitializeGeometry() () from /scif/apps/geant4/lib64/
#8  0x00007f5cbedbb7fa in G4RunManager::Initialize() () from /scif/apps/geant4/lib64/
#9  0x000000000040b940 in main ()

I have sourced the geant and root properly.
Thanks in advance!

Looks as if you might have a problem in UCNBDetectorConstruction::Construct at the point at which you call G4LogicalVolume::SetVisAttributes.

Without more information I cannot say what to might be. Just have a look at your code. Perhaps compile in debug mode so that you get more information when it crashes. And you can step through your program to see what’s happening.

A typical error would be to instantiate a local G4VisAttributes, then pass the address to G4LogicalVolume, which then becomes invalid when the G4VisAttributes object goes out of scope. The solution would be to create a long lasting G4VisAttributes with new.

1 Like

Thank you !
It worked.