Problem 2009

Summary: Valgrind reports "unitialized values" with G4IonisParamMat constructor
Product: Geant4 Reporter: Michael Kelsey <kelsey>
Component: materialsAssignee: Marc.Verderi
Status: RESOLVED FIXED    
Severity: minor CC: Vladimir.Ivantchenko
Priority: P4    
Version: 10.2   
Hardware: All   
OS: All   

Description Michael Kelsey 2017-10-21 04:38:46 CEST
Running Valgrind (--tool=memcheck) generates a report when the "derived material" construction is used, for example to create a new material with a different density than one which is already defined.  My code for this looks like:

  // Kapton tape, used for striplines (data from NIST)
  // Cirlex, bulk Kapton, used for circuit boards
  void CDMSMaterialTable::CreateKapton() {
    G4Material* kapton = new G4Material("Kapton", 1.42*g/cm3, 4);
    kapton->AddElement(nist->FindOrBuildElement("H"), 0.026362);
    kapton->AddElement(nist->FindOrBuildElement("C"), 0.691133);
    kapton->AddElement(nist->FindOrBuildElement("N"), 0.073270);
    kapton->AddElement(nist->FindOrBuildElement("O"), 0.209235);

    new G4Material("Cirlex", kapton->GetDensity(), kapton);
  }

In Valgrind, this produces six reports, all essentially identical (only the pointer locations of "nearbyint" differ):

==4808== Conditional jump or move depends on uninitialised value(s)
==4808==    at 0x107459830: nearbyint$fenv_access_off (in /usr/lib/system/libsystem_m.dylib)
==4808==    by 0x1043D96BE: G4IonisParamMat::G4IonisParamMat(G4Material*) (in /Applications/GEANT4/geant4.10.02-seq/lib/libG4materials.dylib)
==4808==    by 0x1043E300C: G4Material::CopyPointersOfBaseMaterial() (in /Applications/GEANT4/geant4.10.02-seq/lib/libG4materials.dylib)
==4808==    by 0x1043E2E33: G4Material::G4Material(G4String const&, double, G4Material const*, G4State, double, double) (in /Applications/GEANT4/geant4.10.02-seq/lib/libG4materials.dylib)
==4808==    by 0x10038C242: CDMSMaterialTable::CreateKapton() (CDMSMaterialTable.cc:228)
==4808==    by 0x10038A8D2: CDMSMaterialTable::CDMSMaterialTable() (CDMSMaterialTable.cc:112)
==4808==    by 0x10038A084: CDMSMaterialTable::CDMSMaterialTable() (CDMSMaterialTable.cc:83)
==4808==    by 0x10038A02A: CDMSMaterialTable::Instance() (CDMSMaterialTable.cc:75)
==4808==    by 0x10006B4D0: CDMSGeomConstructor::CDMSGeomConstructor() (CDMSGeomConstructor.cc:147)
==4808==    by 0x10006B674: CDMSGeomConstructor::CDMSGeomConstructor() (CDMSGeomConstructor.cc:144)
==4808==    by 0x100001BEE: SuperSim_Main::Configure(G4String const&) (SuperSim_Main.cc:85)
==4808==    by 0x1000013DF: main (CDMS_SimDraw.cc:20)

This is present in 10.2 and 10.3, and probably earlier releases as well.
Comment 1 Vladimir.Ivantchenko 2017-12-12 15:15:44 CET
Mike,

can you, please, re-check if 10.4 has the problem. It should disappear. 

Cheers,
Vladimir
Comment 2 Michael Kelsey 2017-12-18 16:51:26 CET
(In reply to Vladimir.Ivantchenko from comment #1)
> can you, please, re-check if 10.4 has the problem. It should disappear. 

Hi, Vladimir.  This specific message (G4Material => G4IonisParamMat leaks) is gone in 10.4.  However, there are several new leak messages coming from a variety of places in the physics list (mostly hadronics).  I think this bug report can be closed.

  -- Mike Kelsey