Problem 1754 - G4RandGauss::setFlag() crashes every time (Windows)
Summary: G4RandGauss::setFlag() crashes every time (Windows)
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: config (show other problems)
Version: 10.1
Hardware: PC Windows
: P5 normal
Assignee: Gabriele Cosmo
URL:
Depends on:
Blocks:
 
Reported: 2015-06-08 17:12 CEST by Tom Roberts
Modified: 2015-06-25 15:24 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Tom Roberts 2015-06-08 17:12:55 CEST
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})
Comment 1 Gabriele Cosmo 2015-06-10 13:59:09 CEST
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?
Comment 2 Gabriele Cosmo 2015-06-25 15:24:38 CEST
Fix is now provided in CLHEP-2.2.0.8 and last patch to Geant4, 10.1.p02 for the internal module.