Problem 1684

Summary: G4NuclearLevelStore segfaults at exit with user defined files
Product: Geant4 Reporter: Luis Sarmiento Pico <Luis.Sarmiento>
Component: processes/hadronic/models/de_excitation/photon_evaporationAssignee: Vladimir.Ivantchenko
Status: RESOLVED FIXED    
Severity: normal CC: Vladimir.Ivantchenko
Priority: P5    
Version: other   
Hardware: All   
OS: All   

Description Luis Sarmiento Pico 2014-10-31 10:39:04 CET
When a user defined photon evaporation file is present in the destructor there is an attempt to delete G4String as part of the map used to store the filenames.

Unlike the other maps, the "second" component of theUserDataFiles is not a pointer.

Here is a proposed patch to fix this issue:

diff --git a/source/processes/hadronic/models/de_excitation/photon_evaporation/src/G4NuclearLevelStore.cc b/source/processes/hadronic/models/de_excitation/photon_evaporation/src/G4NuclearLevelStore.cc
index 21122ca..1bf2461 100644
--- a/source/processes/hadronic/models/de_excitation/photon_evaporation/src/G4NuclearLevelStore.cc
+++ b/source/processes/hadronic/models/de_excitation/photon_evaporation/src/G4NuclearLevelStore.cc
@@ -71,11 +71,13 @@ G4NuclearLevelStore::~G4NuclearLevelStore()
   MapForHEP::iterator j;
   for (j = managersForHEP.begin(); j != managersForHEP.end(); ++j)
     { delete j->second; }
-  if(userFiles) {
-    std::map<G4int, G4String>::iterator k;
-    for (k = theUserDataFiles.begin(); k != theUserDataFiles.end(); ++k)
-      { delete k->second; }
-  }
+
+  // G4String cannot be deleted since it is not pointer.  we can clear
+  // the map ourselves to be consistent but this should happen
+  // automatically.
+
+  // No need to check for Boolean userFiles
+  theUserDataFiles.clear();
 }
Comment 1 Vladimir.Ivantchenko 2014-11-12 11:49:47 CET
Hello,
Thank you for the clear report on the problem. The bug is fixed and the fix will be available with the next public release 10.1, December 2014.

VI
Comment 2 Vladimir.Ivantchenko 2014-11-16 13:20:12 CET
Hello,

Thank you for the clear report. The bug is fixed and the fix will be available with the new Geant4 version December, 2014.

VI