Segmentation fault (core dumped) error

I am able to complile a very basic code for detector construction but when I run it it does not show me the interactive pop-up window for visualization in Geant4. Instead I get the error: Segmentation fault (core dumped). Can someone help me solve the issue?


cmake_minimum_required(VERSION 2.6 FATAL_ERROR)


find_package(Geant4 REQUIRED ui_all vis_all)


file(GLOB sources ${PROJECT_SOURCE_DIR}/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/*.hh)

add_executable(sim ${sources} ${headers})
target_link_libraries(sim ${Geant4_LIBRARIES})

add_custom_target(Simulation DEPENDS sim)

I am also attaching the relevant files where I think the problem might be.

I was able to visualize it before I tried implementing the sensitive detector part in :

void MyDetectorConstruction::ConstructSDandField()
    MySensitiveDetector *sensDet = new MySensitiveDetector("SensitiveDetector");

} (3.4 KB)
construction.hh (839 Bytes) (263 Bytes)
detector.hh (303 Bytes)

Did you try to see if your simulation goes in your method ConstructSDandField just by print a number or smthg inside ?

With segfaults, the best solution is always to run the application through a debugger such as GDB which can trace which sequence of code/line causes the problem. See this post: Using gdb debugger in an efficient way for some guidance here, or search of GDB on the forums or places like Stack Overflow.