Problem 600 - Leak with G4LowEnergyIonisation
Summary: Leak with G4LowEnergyIonisation
Status: RESOLVED LATER
Alias: None
Product: Geant4
Classification: Unclassified
Component: processes/electromagnetic/lowenergy (show other problems)
Version: 6.0
Hardware: PC Linux
: P2 normal
Assignee: Vladimir.Ivantchenko
URL:
Depends on:
Blocks:
 
Reported: 2004-03-11 11:06 CET by corneliu
Modified: 2004-06-29 09:00 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 corneliu 2004-03-11 11:06:21 CET
Hi,
 I have encountered a problem using the G4LowEnergyIonisation process. I am
using this process for protons, generic ions and charged hadrons. At run time
there is a segmentation fault at the completion of the simulation. I ran the
program with valgrind using $ valgrind --skin=memcheck --leak-check=yes program
run.mac and encountered the following messages:

hLowEIoni:    Knock-on electron cross sections .
        Good description above the mean excitation energy.
        Delta ray energy sampled from  differential Xsection.
        PhysicsTables from 10 eV  to 0.1 TeV  in 360 bins.
        Electronic stopping power model is  ICRU_R49p
        from 1 keV  to 2 MeV .

        Parametrisation model for antiprotons is  ICRU_R49p
        from 25 keV  to 2 MeV .
        Parametrization of the Barkas effect is switched on.
        Nuclear stopping power model is ICRU_R49

msc:  Model variant of multiple scattering for proton
      Lambda tables from 100 eV  to 100 TeV in 120 bins.
      Boundary algorithm is active with facrange= 0.199
==4176== Invalid write of size 4
==4176==    at 0x409EF60D:
G4hLowEnergyIonisation::BuildPhysicsTable(G4ParticleDefinition const&) (in
/usr/local/geant4.6.0/lib/Linux-g++/libG4emlowenergy.so)
==4176==    by 0x40D8025C:
G4VUserPhysicsList::BuildPhysicsTable(G4ParticleDefinition*) (in
/usr/local/geant4.6.0/lib/Linux-g++/libG4run.so)
==4176==    by 0x40D8000B: G4VUserPhysicsList::BuildPhysicsTable() (in
/usr/local/geant4.6.0/lib/Linux-g++/libG4run.so)
==4176==    by 0x40D6B2B2: G4RunManagerKernel::BuildPhysicsTables() (in
/usr/local/geant4.6.0/lib/Linux-g++/libG4run.so)
==4176==    Address 0x43D35DA0 is 0 bytes after a block of size 40 alloc'd
==4176==    at 0x40029886: __builtin_vec_new (vg_replace_malloc.c:203)
==4176==    by 0x400298DD: operator new[](unsigned) (vg_replace_malloc.c:216)
==4176==    by 0x409F79F6: __static_initialization_and_destruction_0(int, int)
(in /usr/local/geant4.6.0/lib/Linux-g++/libG4emlowenergy.so)
==4176==    by 0x409F7B81: _GLOBAL__I__ZN16G4hLowEnergyLoss17NumberOfProcessesE
(in /usr/local/geant4.6.0/lib/Linux-g++/libG4emlowenergy.so)

.........................................
....and then at the end of the simulation
.........................................

Graphics systems deleted.
Visualization Manager deleting...
==4176==
==4176== ERROR SUMMARY: 13 errors from 1 contexts (suppressed: 0 from 0)
==4176== malloc/free: in use at exit: 14866344 bytes in 148989 blocks.
==4176== malloc/free: 283528 allocs, 134539 frees, 81357763 bytes allocated.
==4176== For counts of detected errors, rerun with: -v
==4176== searching for pointers to 148989 not-freed blocks.
==4176== checked 36986724 bytes.
==4176==
==4176==
==4176== 2693 bytes in 473 blocks are definitely lost in loss record 1 of 6
==4176==    at 0x40029886: __builtin_vec_new (vg_replace_malloc.c:203)
==4176==    by 0x400298DD: operator new[](unsigned) (vg_replace_malloc.c:216)
==4176==    by 0x409F79D0: __static_initialization_and_destruction_0(int, int)
(in /usr/local/geant4.6.0/lib/Linux-g++/libG4emlowenergy.so)
==4176==    by 0x409F7B81: _GLOBAL__I__ZN16G4hLowEnergyLoss17NumberOfProcessesE
(in /usr/local/geant4.6.0/lib/Linux-g++/libG4emlowenergy.so)
==4176==
==4176==
==4176== 4552 bytes in 168 blocks are definitely lost in loss record 2 of 6
==4176==    at 0x4002978F: __builtin_new (vg_replace_malloc.c:172)
==4176==    by 0x400297E6: operator new(unsigned) (vg_replace_malloc.c:185)
==4176==    by 0x411711A8: G4UnitDefinition::G4UnitDefinition(G4String const&,
G4String const&, G4String const&, double) (in
/usr/local/geant4.6.0/lib/Linux-g++/libG4globman.so)
==4176==    by 0x41172020: G4UnitDefinition::BuildUnitsTable() (in
/usr/local/geant4.6.0/lib/Linux-g++/libG4globman.so)
==4176==
==4176==
==4176== 316984 bytes in 538 blocks are possibly lost in loss record 3 of 6
==4176==    at 0x4002978F: __builtin_new (vg_replace_malloc.c:172)
==4176==    by 0x400297E6: operator new(unsigned) (vg_replace_malloc.c:185)
==4176==    by 0x41472830: std::__default_alloc_template<true,
0>::_S_chunk_alloc(unsigned, int&) (in /usr/lib/libstdc++.so.5.0.3)
==4176==    by 0x4147273C: std::__default_alloc_template<true,
0>::_S_refill(unsigned) (in /usr/lib/libstdc++.so.5.0.3)
==4176==
==4176==
==4176== 2124092 bytes in 2930 blocks are possibly lost in loss record 4 of 6
==4176==    at 0x40029886: __builtin_vec_new (vg_replace_malloc.c:203)
==4176==    by 0x400298DD: operator new[](unsigned) (vg_replace_malloc.c:216)
==4176==    by 0x40439335: G4NeutronHPElementData::Init(G4Element*) (in
/usr/local/geant4.6.0/lib/Linux-g++/libG4had_neu_hp.so)
==4176==    by 0x4042CC8F: G4NeutronHPData::G4NeutronHPData() (in
/usr/local/geant4.6.0/lib/Linux-g++/libG4had_neu_hp.so)
==4176==
==4176== LEAK SUMMARY:
==4176==    definitely lost: 7245 bytes in 641 blocks.
==4176==    possibly lost:   2441076 bytes in 3468 blocks.
==4176==    still reachable: 12418023 bytes in 144880 blocks.
==4176==         suppressed: 0 bytes in 0 blocks.
==4176== Reachable blocks (those to which a pointer was found) are not shown.
==4176== To see them, rerun with: --show-reachable=yes

I was previously using G4hIonisation for protons and charged hadrons and
G4ionIonisation for ions and did not encounter the segmentation fault, although
there were some of the other leak errors.

I am running the latest release (with patch) under linux redhat 9.0 gcc version
3.2.2 20030222 CLHEP 1.8.0

If you would like further details of the simulation please email and i will
forward the source.

Best Regards,
Iwan
Comment 1 Maria.Grazia.Pia 2004-03-11 11:11:59 CET
The problem report is re-assigned to the developer responsible for this class
(I understand that the problem is with G4hLowEnergyhIonisation, not with
G4LowEnergyIonisation).

Best wishes,
Maria Grazia
Comment 2 sandor.voros 2004-06-29 09:00:59 CEST
Just a little addition concerning this problem: I used the
G4hLowEnergyIonisation class in Geant4.6.2 (latest release) and got the same
error from Valgrind. Since I compiled the code with the debug option I got a
little bit more information (see Valgrind output at the end of this message).
In summary it appears that the two lines where the problem occurs are lines
number 314 and 320 in file G4hLowEnergyIonisation.cc, which read

        RecorderOfpProcess[CounterOfpProcess] = theLossTable ;
and
        RecorderOfpbarProcess[CounterOfpbarProcess] = theLossTable ;

due to the index of the arrays being larger than the actual array dimensions,
which were set on lines 78 and 82 of file G4hLowEnergyLoss.cc respectively

G4PhysicsTable** G4hLowEnergyLoss::RecorderOfpProcess =
                                           new G4PhysicsTable*[10] ;
and
G4PhysicsTable** G4hLowEnergyLoss::RecorderOfpbarProcess =
                                           new G4PhysicsTable*[10] ;

Hope this helps,
SĂĄndor



P.S.: Valgrind's output:

..........
msc:  Model variant of multiple scattering for proton
      Lambda tables from 100 eV  to 100 TeV in 120 bins.
      Boundary algorithm is active with facrange= 0.199
==4160==
==4160== Invalid write of size 4
==4160==    at 0x413CE434:
G4hLowEnergyIonisation::BuildPhysicsTable(G4ParticleDefinition const&)
(G4hLowEnergyIonisation.cc:314)
==4160==    by 0x41B1A713:
G4VUserPhysicsList::BuildPhysicsTable(G4ParticleDefinition*)
(G4VUserPhysicsList.cc:434)
==4160==    by 0x41B1A4AA: G4VUserPhysicsList::BuildPhysicsTable()
(G4VUserPhysicsList.cc:391)
==4160==    by 0x41B0550A: G4RunManagerKernel::BuildPhysicsTables()
(G4RunManagerKernel.cc:306)
==4160==    by 0x41B05384: G4RunManagerKernel::RunInitialization()
(G4RunManagerKernel.cc:262)
==4160==    by 0x41B08B57: G4RunManager::RunInitialization()
(G4RunManager.cc:166)
==4160==    by 0x41B08914: G4RunManager::BeamOn(int, char const*, int)
(G4RunManager.cc:126)
==4160==    by 0x41B0FDD1: G4RunMessenger::SetNewValue(G4UIcommand*, G4String)
(G4RunMessenger.cc:248)
==4160==    by 0x4214E13D: G4UIcommand::DoIt(G4String) (G4UIcommand.cc:206)
==4160==    by 0x42160454: G4UImanager::ApplyCommand(char const*)
(G4UImanager.cc:397)
==4160==    by 0x4215FE47: G4UImanager::ApplyCommand(G4String)
(G4UImanager.cc:341)
==4160==    by 0x4080DDFA: G4UIterminal::ExecuteCommand(G4String)
(G4UIterminal.cc:105)
==4160==    by 0x4080DB9E: G4UIterminal::SessionStart() (G4UIterminal.cc:80)
==4160==    by 0x805214C: main (totabs.cc:126)
==4160==    by 0x42704916: __libc_start_main (in /lib/libc-2.3.2.so)
==4160==    by 0x8051914: ??? (start.S:81)
==4160==    Address 0x47EDBE74 is 0 bytes after a block of size 40 alloc'd
==4160==    at 0x40029886: __builtin_vec_new (vg_replace_malloc.c:203)
==4160==    by 0x400298DD: operator new[](unsigned) (vg_replace_malloc.c:216)
==4160==    by 0x413DA365: __static_initialization_and_destruction_0(int, int)
(G4hLowEnergyLoss.cc:78)
==4160==    by 0x413DA582: _GLOBAL__I__ZN16G4hLowEnergyLoss17NumberOfProcessesE
(G4ProductionCutsTable.hh:98)
==4160==    by 0x4142C67C: (within
/usr/local/share/geant4/debug/lib/Linux-g++/libG4emlowenergy.so)
==4160==    by 0x41393598: (within
/usr/local/share/geant4/debug/lib/Linux-g++/libG4emlowenergy.so)
==4160==    by 0x4000C4B0: _dl_init_internal (in /lib/ld-2.3.2.so)
==4160==    by 0x40000C1C: (within /lib/ld-2.3.2.so)
==4160==
==4160== ---- Print suppression ? --- [Return/N/n/Y/y/C/c] ----

msc:  Model variant of multiple scattering for mu+
      Lambda tables from 100 eV  to 100 TeV in 120 bins.
      Boundary algorithm is active with facrange= 0.199
==4160==
==4160== Invalid write of size 4
==4160==    at 0x413CE472:
G4hLowEnergyIonisation::BuildPhysicsTable(G4ParticleDefinition const&)
(G4hLowEnergyIonisation.cc:320)
==4160==    by 0x41B1A713:
G4VUserPhysicsList::BuildPhysicsTable(G4ParticleDefinition*)
(G4VUserPhysicsList.cc:434)
==4160==    by 0x41B1A4AA: G4VUserPhysicsList::BuildPhysicsTable()
(G4VUserPhysicsList.cc:391)
==4160==    by 0x41B0550A: G4RunManagerKernel::BuildPhysicsTables()
(G4RunManagerKernel.cc:306)
==4160==    by 0x41B05384: G4RunManagerKernel::RunInitialization()
(G4RunManagerKernel.cc:262)
==4160==    by 0x41B08B57: G4RunManager::RunInitialization()
(G4RunManager.cc:166)
==4160==    by 0x41B08914: G4RunManager::BeamOn(int, char const*, int)
(G4RunManager.cc:126)
==4160==    by 0x41B0FDD1: G4RunMessenger::SetNewValue(G4UIcommand*, G4String)
(G4RunMessenger.cc:248)
==4160==    by 0x4214E13D: G4UIcommand::DoIt(G4String) (G4UIcommand.cc:206)
==4160==    by 0x42160454: G4UImanager::ApplyCommand(char const*)
(G4UImanager.cc:397)
==4160==    by 0x4215FE47: G4UImanager::ApplyCommand(G4String)
(G4UImanager.cc:341)
==4160==    by 0x4080DDFA: G4UIterminal::ExecuteCommand(G4String)
(G4UIterminal.cc:105)
==4160==    by 0x4080DB9E: G4UIterminal::SessionStart() (G4UIterminal.cc:80)
==4160==    by 0x805214C: main (totabs.cc:126)
==4160==    by 0x42704916: __libc_start_main (in /lib/libc-2.3.2.so)
==4160==    by 0x8051914: ??? (start.S:81)
==4160==    Address 0x47EDBECC is 0 bytes after a block of size 40 alloc'd
==4160==    at 0x40029886: __builtin_vec_new (vg_replace_malloc.c:203)
==4160==    by 0x400298DD: operator new[](unsigned) (vg_replace_malloc.c:216)
==4160==    by 0x413DA389: __static_initialization_and_destruction_0(int, int)
(G4hLowEnergyLoss.cc:82)
==4160==    by 0x413DA582: _GLOBAL__I__ZN16G4hLowEnergyLoss17NumberOfProcessesE
(G4ProductionCutsTable.hh:98)
==4160==    by 0x4142C67C: (within
/usr/local/share/geant4/debug/lib/Linux-g++/libG4emlowenergy.so)
==4160==    by 0x41393598: (within
/usr/local/share/geant4/debug/lib/Linux-g++/libG4emlowenergy.so)
==4160==    by 0x4000C4B0: _dl_init_internal (in /lib/ld-2.3.2.so)
==4160==    by 0x40000C1C: (within /lib/ld-2.3.2.so)
==4160==
==4160== ---- Print suppression ? --- [Return/N/n/Y/y/C/c] ----

msc:  Model variant of multiple scattering for pi-
      Lambda tables from 100 eV  to 100 TeV in 120 bins.
      Boundary algorithm is active with facrange= 0.199
..........