Problem with ***Breack*** segmentation violation

Hello, root developers.
I’ ve tried to compile a geant4-root program, but with many different warnings.

localhost.localdomain:/build < 71 >make 
Scanning dependencies of target TPC-MC
[  5%] Building CXX object CMakeFiles/TPC-MC.dir/TPC-MC.cc.o
[ 10%] Building CXX object CMakeFiles/TPC-MC.dir/src/TPCAnalysisManager.cc.o
In file included from /usr/local/root/6.06.02/include/root/TObject.h:238:0,
                 from /usr/local/root/6.06.02/include/root/TNamed.h:26,
                 from /usr/local/root/6.06.02/include/root/TDirectory.h:25,
                 from /usr/local/root/6.06.02/include/root/TROOT.h:29,
                 from /home/local1/Desktop/tpcc/src/TPCAnalysisManager.cc:13:
/usr/local/root/6.06.02/include/root/TBuffer.h: In function ‘TBuffer& operator>>(TBuffer&, Short_t&)’:
/usr/local/root/6.06.02/include/root/TBuffer.h:333:52: warning: declaration of ‘s’ shadows a global declaration [-Wshadow]
 inline TBuffer &operator>>(TBuffer &buf, Short_t &s)  { buf.ReadShort(s);  return buf; }
                                                    ^

So on, it finished with

/usr/local/root/6.06.02/include/root/TString.h: In member function ‘TString& TString::Replace(Ssiz_t, Ssiz_t, const TString&, Ssiz_t)’:
/usr/local/root/6.06.02/include/root/TString.h:632:43: warning: declaration of ‘s’ shadows a global declaration [-Wshadow]
                                  Ssiz_t n2)
                                           ^
/usr/local/root/6.06.02/include/root/TString.h: In member function ‘TSubString& TSubString::operator=(const TSubString&)’:
/usr/local/root/6.06.02/include/root/TString.h:695:61: warning: declaration of ‘s’ shadows a global declaration [-Wshadow]
 inline TSubString &TSubString::operator=(const TSubString &s)
                                                             ^
In file included from /home/local1/Desktop/tpcc/src/TPCParticleSourceMessenger.cc:20:0:
/home/local1/Desktop/tpcc/include/TPCParticleSource.hh: At global scope:
/home/local1/Desktop/tpcc/include/TPCParticleSource.hh:47:35: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
  const G4double GetParticleEnergy() { return m_dParticleEnergy; }
                                   ^
[ 90%] Building CXX object CMakeFiles/TPC-MC.dir/src/TPCPhysicsList.cc.o
[ 95%] Building CXX object CMakeFiles/TPC-MC.dir/src/TPCEventAction.cc.o
[100%] Linking CXX executable TPC-MC
[100%] Built target TPC-MC

Also, there are some warning with

/home/local1/Desktop/tpcc/src/TPCDetectorConstruction.cc:1328:53: warning: ISO C++ forbids variable length array ‘pdGridMeshSupportZ’ [-Wvla]
   G4double pdGridMeshSupportZ[dGridMeshSupportNumber];
                                                     ^
/home/local1/Desktop/tpcc/src/TPCDetectorConstruction.cc:1365:45: warning: ISO C++ forbids variable length array ‘pdGridMeshBorderZ’ [-Wvla]
   G4double pdGridMeshBorderZ[dGridMeshNumber]; 
                                             ^
/home/local1/Desktop/tpcc/src/TPCDetectorConstruction.cc:1393:39: warning: ISO C++ forbids variable length array ‘pdGridMeshZ’ [-Wvla]
   G4double pdGridMeshZ[dGridMeshNumber]; 

I have the executable but when I want to use that there is a crash

localhost.localdomain:/build < 37 >./TPC-MC -f ./macros/src_optPhot_DP.mac -o optPhot_1e8.root -n 100000000
===========================================
Starting TPC-Simulation ...
===========================================

*************************************************************
 Geant4 version Name: geant4-10-02-patch-02 [MT]   (17-June-2016)
                      Copyright : Geant4 Collaboration
                      Reference : NIM A 506 (2003), 250-303
                            WWW : http://cern.ch/geant4
*************************************************************

Visualization Manager instantiating with verbosity "warnings (3)"...
Visualization Manager initialising...
Registering graphics systems...

You have successfully registered the following graphics systems.
Current available graphics systems are:
ASCIITree (ATree)
DAWNFILE (DAWNFILE)
G4HepRep (HepRepXML)
G4HepRepFile (HepRepFile)
RayTracer (RayTracer)
VRML1FILE (VRML1FILE)
VRML2FILE (VRML2FILE)
gMocrenFile (gMocrenFile)
OpenGLImmediateQt (OGLIQt, OGLI)
OpenGLStoredQt (OGLSQt, OGL, OGLS)
OpenGLImmediateXm (OGLIXm, OGLIQt_FALLBACK)
OpenGLStoredXm (OGLSXm, OGLSQt_FALLBACK)
OpenGLImmediateX (OGLIX, OGLIQt_FALLBACK, OGLIXm_FALLBACK)
OpenGLStoredX (OGLSX, OGLSQt_FALLBACK, OGLSXm_FALLBACK)

Registering model factories...

You have successfully registered the following model factories.
Registered model factories:
  generic
  drawByCharge
  drawByParticleID
  drawByOriginVolume
  drawByAttribute

Registered filter factories:
  chargeFilter
  particleFilter
  originVolumeFilter
  attributeFilter

You have successfully registered the following user vis actions.
Run Duration User Vis Actions: none
End of Event User Vis Actions: none
End of Run User Vis Actions: none

Some /vis commands (optionally) take a string to specify colour.
Available colours:
  black, blue, brown, cyan, gray, green, grey, magenta, red, white, yellow


 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007fbf297beb0c in waitpid () at /usr/lib64/libc.so.6
#1  0x00007fbf29743092 in do_system () at /usr/lib64/libc.so.6
#2  0x00007fbf35110e19 in TUnixSystem::StackTrace() () at /usr/local/root/6.06.02/lib/root/libCore.so.6.06
#3  0x00007fbf3511349c in TUnixSystem::DispatchSignals(ESignals) () at /usr/local/root/6.06.02/lib/root/libCore.so.6.06
#4  0x00007fbf29ad2100 in <signal handler called> () at /usr/lib64/libpthread.so.0
#5  0x00007fbf2b454166 in G4LogicalVolume::AddDaughter(G4VPhysicalVolume*) (this=0x3730310a300a3233) at /usr/local/src/geant4.10.02.p02/source/geometry/management/include/G4LogicalVolume.icc:91
#6  0x00007fbf2b454166 in G4LogicalVolume::AddDaughter(G4VPhysicalVolume*) (this=0xca0670, pNewDaughter=0xca2630) at /usr/local/src/geant4.10.02.p02/source/geometry/management/include/G4LogicalVolume.icc:173
#7  0x00007fbf2b45293f in G4PVPlacement::G4PVPlacement(CLHEP::HepRotation*, CLHEP::Hep3Vector const&, G4LogicalVolume*, G4String const&, G4LogicalVolume*, bool, int, bool) (this=0xca2630, pRot=<optimized out>, tlate=..., pCurrentLogical=0x3730310a300a3233, pName=..., pMotherLogical=0xca0670, pMany=false, pCopyNo=0, pSurfChk=false) at /usr/local/src/geant4.10.02.p02/source/geometry/volumes/src/G4PVPlacement.cc:117
#8  0x000000000045fe3b in TPCDetectorConstruction::ConstructTPC() ()
#9  0x0000000000455535 in TPCDetectorConstruction::Construct() ()
#10 0x00007fbf2e55e06f in G4RunManager::InitializeGeometry() (this=0x85c840) at /usr/local/src/geant4.10.02.p02/source/run/src/G4RunManager.cc:581
#11 0x00007fbf2e55dfa1 in G4RunManager::Initialize() (this=0x85c840) at /usr/local/src/geant4.10.02.p02/source/run/src/G4RunManager.cc:565
#12 0x00007fbf2e576279 in G4RunMessenger::SetNewValue(G4UIcommand*, G4String) (this=0xa55cb0, command=command
entry=0xa55ee0, newValue=...) at /usr/local/src/geant4.10.02.p02/source/run/src/G4RunMessenger.cc:488
#13 0x00007fbf2ab0dd25 in G4UIcommand::DoIt(G4String) (this=this
entry=0xa55ee0, parameterList=...) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UIcommand.cc:230
#14 0x00007fbf2ab25e08 in G4UImanager::ApplyCommand(char const*) (this=0x799ca0, aCmd=<optimized out>) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UImanager.cc:523
#15 0x00007fbf2ab268b8 in G4UImanager::ApplyCommand(G4String const&) (this=<optimized out>, aCmd=...) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UImanager.cc:441
#16 0x00007fbf2aafe31d in G4UIbatch::ExecCommand(G4String const&) (this=this
entry=0xc44ba0, command=...) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UIbatch.cc:170
#17 0x00007fbf2aaff9bb in G4UIbatch::SessionStart() (this=0xc44ba0) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UIbatch.cc:215
#18 0x00007fbf2ab210b3 in G4UImanager::ExecuteMacroFile(char const*) (this=this
entry=0x799ca0, fileName=0xc44b78 "macros/preinit.mac") at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UImanager.cc:296
#19 0x00007fbf2ab17509 in G4UIcontrolMessenger::SetNewValue(G4UIcommand*, G4String) (this=0x79a0b0, command=command
entry=0x79a7b0, newValue=...) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UIcontrolMessenger.cc:313
#20 0x00007fbf2ab0dd25 in G4UIcommand::DoIt(G4String) (this=this
entry=0x79a7b0, parameterList=...) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UIcommand.cc:230
#21 0x00007fbf2ab25e08 in G4UImanager::ApplyCommand(char const*) (this=0x799ca0, aCmd=<optimized out>) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UImanager.cc:523
#22 0x000000000043e762 in main ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x00007fbf2b454166 in G4LogicalVolume::AddDaughter(G4VPhysicalVolume*) (this=0x3730310a300a3233) at /usr/local/src/geant4.10.02.p02/source/geometry/management/include/G4LogicalVolume.icc:91
#6  0x00007fbf2b454166 in G4LogicalVolume::AddDaughter(G4VPhysicalVolume*) (this=0xca0670, pNewDaughter=0xca2630) at /usr/local/src/geant4.10.02.p02/source/geometry/management/include/G4LogicalVolume.icc:173
#7  0x00007fbf2b45293f in G4PVPlacement::G4PVPlacement(CLHEP::HepRotation*, CLHEP::Hep3Vector const&, G4LogicalVolume*, G4String const&, G4LogicalVolume*, bool, int, bool) (this=0xca2630, pRot=<optimized out>, tlate=..., pCurrentLogical=0x3730310a300a3233, pName=..., pMotherLogical=0xca0670, pMany=false, pCopyNo=0, pSurfChk=false) at /usr/local/src/geant4.10.02.p02/source/geometry/volumes/src/G4PVPlacement.cc:117
#8  0x000000000045fe3b in TPCDetectorConstruction::ConstructTPC() ()
#9  0x0000000000455535 in TPCDetectorConstruction::Construct() ()
#10 0x00007fbf2e55e06f in G4RunManager::InitializeGeometry() (this=0x85c840) at /usr/local/src/geant4.10.02.p02/source/run/src/G4RunManager.cc:581
#11 0x00007fbf2e55dfa1 in G4RunManager::Initialize() (this=0x85c840) at /usr/local/src/geant4.10.02.p02/source/run/src/G4RunManager.cc:565
#12 0x00007fbf2e576279 in G4RunMessenger::SetNewValue(G4UIcommand*, G4String) (this=0xa55cb0, command=command
entry=0xa55ee0, newValue=...) at /usr/local/src/geant4.10.02.p02/source/run/src/G4RunMessenger.cc:488
#13 0x00007fbf2ab0dd25 in G4UIcommand::DoIt(G4String) (this=this
entry=0xa55ee0, parameterList=...) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UIcommand.cc:230
#14 0x00007fbf2ab25e08 in G4UImanager::ApplyCommand(char const*) (this=0x799ca0, aCmd=<optimized out>) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UImanager.cc:523
#15 0x00007fbf2ab268b8 in G4UImanager::ApplyCommand(G4String const&) (this=<optimized out>, aCmd=...) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UImanager.cc:441
#16 0x00007fbf2aafe31d in G4UIbatch::ExecCommand(G4String const&) (this=this
entry=0xc44ba0, command=...) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UIbatch.cc:170
#17 0x00007fbf2aaff9bb in G4UIbatch::SessionStart() (this=0xc44ba0) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UIbatch.cc:215
#18 0x00007fbf2ab210b3 in G4UImanager::ExecuteMacroFile(char const*) (this=this
entry=0x799ca0, fileName=0xc44b78 "macros/preinit.mac") at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UImanager.cc:296
#19 0x00007fbf2ab17509 in G4UIcontrolMessenger::SetNewValue(G4UIcommand*, G4String) (this=0x79a0b0, command=command
entry=0x79a7b0, newValue=...) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UIcontrolMessenger.cc:313
#20 0x00007fbf2ab0dd25 in G4UIcommand::DoIt(G4String) (this=this
entry=0x79a7b0, parameterList=...) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UIcommand.cc:230
#21 0x00007fbf2ab25e08 in G4UImanager::ApplyCommand(char const*) (this=0x799ca0, aCmd=<optimized out>) at /usr/local/src/geant4.10.02.p02/source/intercoms/src/G4UImanager.cc:523
#22 0x000000000043e762 in main ()

Your suggestion was I need to compile in debug mode to get more useful information and run the code with a debugger such as gdb. I did that with

make all VERBOSE=1

I made a GNUMakefle but is the same. Could you suggest me? What else I have to do in order to solve this problem?. I thought is the version because there are problems with root libraries.

Best regards.

Hi,

this looks like a problem in the application based on G4 and ROOT and not on the libraries themselves on the other hand. For example, the declarations of the arrays are in the TPCDetectorConstruction.cc file as well as the “s” variable…

Cheers,
D

This does look like an issue with the Geant4 portion of your application, but here are some pointers.

VERBOSE=1 will only given you more information about the compilation. You need to change the build type to debug:

cmake -DCMAKE_BUILD_TYPE=Debug ..

This will give you a bit more information in the back trace. In addition, you should find an online resource or a book that discusses how to use gdb (Gnu Debugger) this is a powerful application that will probe your code and allow you to step through it one line at a time and discover problems. At the moment the following lines of the back trace give you a hint that the problem is in the construction of the Geant4 Volumes:

#5  0x00007fbf2b454166 in G4LogicalVolume::AddDaughter(G4VPhysicalVolume*) (this=0x3730310a300a3233) at /usr/local/src/geant4.10.02.p02/source/geometry/management/include/G4LogicalVolume.icc:91
#6  0x00007fbf2b454166 in G4LogicalVolume::AddDaughter(G4VPhysicalVolume*) (this=0xca0670, pNewDaughter=0xca2630) at /usr/local/src/geant4.10.02.p02/source/geometry/management/include/G4LogicalVolume.icc:173
#7  0x00007fbf2b45293f in G4PVPlacement::G4PVPlacement(CLHEP::HepRotation*, CLHEP::Hep3Vector const&, G4LogicalVolume*, G4String const&, G4LogicalVolume*, bool, int, bool) (this=0xca2630, pRot=<optimized out>, tlate=..., pCurrentLogical=0x3730310a300a3233, pName=..., pMotherLogical=0xca0670, pMany=false, pCopyNo=0, pSurfChk=false) at /usr/local/src/geant4.10.02.p02/source/geometry/volumes/src/G4PVPlacement.cc:117
#8  0x000000000045fe3b in TPCDetectorConstruction::ConstructTPC() ()
#9  0x0000000000455535 in TPCDetectorConstruction::Construct() ()

After recompiling in Debug mode and rerunning the application to see if you get more information I would investigate TPCDetectorConstruction::ConstructTPC.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.