| Summary: | example crashes for undefined environment variable | ||
|---|---|---|---|
| Product: | Examples/Advanced | Reporter: | jcook |
| Component: | xray_fluorescence | Assignee: | alfonso.mantero |
| Status: | RESOLVED FIXED | ||
| Severity: | trivial | ||
| Priority: | P5 | ||
| Version: | other | ||
| Hardware: | PC | ||
| OS: | Linux | ||
Thank you for reporting the bug. Actually, it is sufficient to go to the xray_flurescence directory and issue "setenv XRAYDATA=$PWD" in tcsh or the equivalent in bash. actually necessary data files are in the example dir. best regards, Alf |
Steps to reproduce: Install Geant 4.9.5 on a RedHat 4 system with cmake 2.6. Get confused about the new manner of handling data files and decided to forget about them for the moment. Compile xray_fluorescence. Start bin/Linux-g++/XrayFluo. Select 1. Actual result: Program crashes with the following report: ... DeviceSizeY(cm): 0.632456 terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct NULL not valid Aborted User is confused. Expected result: G4Exception thrown. ... DeviceSizeY(cm): 0.632456 -------- EEEE ------- G4Exception-START -------- EEEE ------- *** G4Exception : example-xray_fluorescence07 issued by : XrayFluoSiLiDetectorType::LoadResponseData() XrayFluoSiLiDetectorType - environment variable XRAYDATA not set. *** Fatal Exception *** core dump *** -------- EEEE -------- G4Exception-END --------- EEEE ------- User is not confused. Solution: The problem is that getenv() returns a NULL if the environment variable is not found. In XrayFluoSiLiDetectorType.cc, XrayFluoSiLiDetectorType::LoadResponseData(G4String fileName), make the following change. char* path = getenv("XRAYDATA"); if (path==NULL) { G4ExceptionDescription execp; execp << "XrayFluoSiLiDetectorType - environment variable XRAYDATA not set."; G4Exception("XrayFluoSiLiDetectorType::LoadResponseData()","example-xray_fluorescence07", FatalException, execp); } G4String pathString(path); This is a quite trivial bug, but I suspect that I won't be the only person working without data files (even if only briefly) and the fix would be helpful to novice users.