On Windows, the internal version of CLHEP crashes in G4RandGauss::setFlag(). The "System" version of CLHEP, plus CLHEP 2.1.4.1, is OK. On Linux and Mac the internal version of CLHEP is OK. This is geant4.10.01.p01, on Windows 7 using CMake 3.2.1 and Visual Studio 2013 (VC++ 12). I built Geant4 for 32-bits, dynamic libraries, exceptions enabled, Debug mode. Of course I built the test program the same. (This configuration is dictated by other libraries with which I need to link: Root, GSL, and FFTW.) Note this test program won't work in multi-threaded mode, but that is off. (The original problem calls G4RandGauss::setFlag() from inside GeneratePrimaries() which would be OK in multi-threaded mode.) Here are my test program and its CMakeLists.txt: // RandGaussTest.cc #include <stdio.h> #include "Randomize.hh" int zero() { return 0; } int main() { fprintf(stderr,"A\n"); if(zero() == 0) G4RandGauss::setFlag(false); fprintf(stderr,"B\n"); return 0; } cmake_minimum_required(VERSION 2.6 FATAL_ERROR) project(RandGaussTest) find_package(Geant4 REQUIRED) include(${Geant4_USE_FILE}) add_executable(RandGaussTest RandGaussTest.cc) target_link_libraries(RandGaussTest ${Geant4_LIBRARIES})
This is likely a problem in CLHEP, having to deal with DLL libraries (handling of static data). It may not be seen if using an external installation of CLHEP, since external installations only provide static archives. Can you please try the following modification: move the implementation of RandGauss::setFlag(bool) from the header file to the source, recompile, run your test and let us know?
Fix is now provided in CLHEP-2.2.0.8 and last patch to Geant4, 10.1.p02 for the internal module.