[gmx-developers] [PATCH} Fix for doble free memory coruption in gmx_genion.c

Alexey Shvetsov alexxyum at gmail.com
Fri Feb 19 14:35:40 CET 2010


Hmm...
When i try to run genion on speptide system i get it crushed. So its
double free error. And if i ran genion under valgrind it shows me that
there 2 double free errors exatly on deleted fclose lines
alexxy at fermi ~/speptide-vv-t $ genion -s speptide.em_noions.tpr -o
speptide.ions.gro -p speptide.top -pname NA+ -nname CL- -neutral -pot
-conc 0.02
                         :-)  G  R  O  M  A  C  S  (-:

                     Gyas ROwers Mature At Cryogenic Speed

                     :-)  VERSION 90dc887ddec299776e0c  (-:


      Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
       Copyright (c) 1991-2000, University of Groningen, The Netherlands.
             Copyright (c) 2001-2008, The GROMACS development team,
            check out http://www.gromacs.org for more information.

         This program is free software; you can redistribute it and/or
          modify it under the terms of the GNU General Public License
         as published by the Free Software Foundation; either version 2
             of the License, or (at your option) any later version.

                      :-)  genion (double precision)  (-:

Option     Filename  Type         Description
------------------------------------------------------------
  -s speptide.em_noions.tpr  Input        Run input file: tpr tpb tpa
-table    table.xvg  Input, Opt.  xvgr/xmgr file
  -n      index.ndx  Input, Opt.  Index file
  -o speptide.ions.gro  Output       Structure file: gro g96 pdb etc.
  -g     genion.log  Output       Log file
-pot        pot.pdb  Output, Opt! Protein data bank file
  -p   speptide.top  In/Out, Opt! Topology file

Option       Type   Value   Description
------------------------------------------------------
-[no]h       bool   no      Print help info and quit
-[no]version bool   no      Print version info and quit
-nice        int    19      Set the nicelevel
-xvg         enum   xmgrace  xvg plot formatting: xmgrace, xmgr or none
-np          int    0       Number of positive ions
-pname       string NA+     Name of the positive ion
-pq          int    1       Charge of the positive ion
-nn          int    0       Number of negative ions
-nname       string CL-     Name of the negative ion
-nq          int    -1      Charge of the negative ion
-rmin        real   0.6     Minimum distance between ions
-[no]random  bool   yes     Use random placement of ions instead of based on
                            potential. The rmin option should still work
-seed        int    1993    Seed for random number generator
-scale       real   0.001   Scaling factor for the potential for -pot
-conc        real   0.02    Specify salt concentration (mol/liter). This will
                            add sufficient ions to reach up to the specified
                            concentration as computed from the volume of the
                            cell in the input tpr file. Overrides the -np and
                            nn options.
-[no]neutral bool   yes     This option will add enough ions to neutralize
                            the system. In combination with the concentration
                            option a neutral system at a given salt
                            concentration will be generated.

Not computing potential with random option!

Back Off! I just backed up genion.log to ./#genion.log.2#
Reading file speptide.em_noions.tpr, VERSION
4.0.99_development_20090927 (double precision)
Using a coulomb cut-off of 1.5 nm
Will try to add 2 NA+ ions and 2 CL- ions.
Select a continuous group of solvent molecules
Group     0 (      System) has 12250 elements
Group     1 (     Protein) has   193 elements
Group     2 (   Protein-H) has   146 elements
Group     3 (     C-alpha) has    19 elements
Group     4 (    Backbone) has    57 elements
Group     5 (   MainChain) has    77 elements
Group     6 (MainChain+Cb) has    96 elements
Group     7 ( MainChain+H) has    98 elements
Group     8 (   SideChain) has    95 elements
Group     9 ( SideChain-H) has    69 elements
Group    10 ( Prot-Masses) has   193 elements
Group    11 ( non-Protein) has 12057 elements
Group    12 (         SOL) has 12057 elements
Group    13 (     non-SOL) has   193 elements
Select a group: 12
Selected 12: 'SOL'
Number of (3-atomic) solvent molecules: 4019

Processing topology

Back Off! I just backed up temp.top to ./#temp.top.1#
Replacing 4 solute molecules in topology file (speptide.top)  by 2 NA+
and 2 CL- ions.
*** glibc detected *** genion: double free or corruption (!prev):
0x00000000023d64e0 ***
======= Backtrace: =========
/lib/libc.so.6(+0x71c75)[0x2ba34a25fc75]
/lib/libc.so.6(cfree+0x6c)[0x2ba34a264aac]
/lib/libc.so.6(fclose+0x155)[0x2ba34a250455]
/usr/lib/libgmx_d.so.5(ffclose+0x57)[0x2ba34a7ccd07]
/usr/lib/libgmxana_d.so.5(gmx_genion+0x1209)[0x2ba349d423d9]
/lib/libc.so.6(__libc_start_main+0xfd)[0x2ba34a20cb8d]
genion[0x400599]
======= Memory map: ========
00400000-00401000 r-xp 00000000 fe:04 167987
  /usr/bin/genion
00600000-00601000 r--p 00000000 fe:04 167987
  /usr/bin/genion
00601000-00602000 rw-p 00001000 fe:04 167987
  /usr/bin/genion
022af000-024b7000 rw-p 00000000 00:00 0
  [heap]
2ba349a46000-2ba349a64000 r-xp 00000000 fe:02 8168
  /lib64/ld-2.11.so
2ba349a64000-2ba349a65000 rw-p 00000000 00:00 0
2ba349c63000-2ba349c64000 r--p 0001d000 fe:02 8168
  /lib64/ld-2.11.so
2ba349c64000-2ba349c65000 rw-p 0001e000 fe:02 8168
  /lib64/ld-2.11.so
2ba349c65000-2ba349c66000 rw-p 00000000 00:00 0
2ba349c66000-2ba349d9b000 r-xp 00000000 fe:04 168036
  /usr/lib64/libgmxana_d.so.5.0.0
2ba349d9b000-2ba349f9b000 ---p 00135000 fe:04 168036
  /usr/lib64/libgmxana_d.so.5.0.0
2ba349f9b000-2ba349fa0000 r--p 00135000 fe:04 168036
  /usr/lib64/libgmxana_d.so.5.0.0
2ba349fa0000-2ba349fa4000 rw-p 0013a000 fe:04 168036
  /usr/lib64/libgmxana_d.so.5.0.0
2ba349fa4000-2ba349fcc000 rw-p 00000000 00:00 0
2ba349fd2000-2ba349fd3000 rw-p 00000000 00:00 0
2ba349fd3000-2ba349fe9000 r-xp 00000000 fe:02 8163
  /lib64/libpthread-2.11.so
2ba349fe9000-2ba34a1e8000 ---p 00016000 fe:02 8163
  /lib64/libpthread-2.11.so
2ba34a1e8000-2ba34a1e9000 r--p 00015000 fe:02 8163
  /lib64/libpthread-2.11.so
2ba34a1e9000-2ba34a1ea000 rw-p 00016000 fe:02 8163
  /lib64/libpthread-2.11.so
2ba34a1ea000-2ba34a1ee000 rw-p 00000000 00:00 0
2ba34a1ee000-2ba34a33a000 r-xp 00000000 fe:02 6274
  /lib64/libc-2.11.so
2ba34a33a000-2ba34a53a000 ---p 0014c000 fe:02 6274
  /lib64/libc-2.11.so
2ba34a53a000-2ba34a53e000 r--p 0014c000 fe:02 6274
  /lib64/libc-2.11.so
2ba34a53e000-2ba34a53f000 rw-p 00150000 fe:02 6274
  /lib64/libc-2.11.so
2ba34a53f000-2ba34a544000 rw-p 00000000 00:00 0
2ba34a544000-2ba34a57c000 r-xp 00000000 fe:04 118616
  /usr/lib64/libgslcblas.so.0.0.0
2ba34a57c000-2ba34a77b000 ---p 00038000 fe:04 118616
  /usr/lib64/libgslcblas.so.0.0.0
2ba34a77b000-2ba34a77c000 r--p 00037000 fe:04 118616
  /usr/lib64/libgslcblas.so.0.0.0
2ba34a77c000-2ba34a77d000 rw-p 00038000 fe:04 118616
  /usr/lib64/libgslcblas.so.0.0.0
2ba34a77d000-2ba34a77e000 rw-p 00000000 00:00 0
2ba34a77e000-2ba34a97b000 r-xp 00000000 fe:04 168033
  /usr/lib64/libgmx_d.so.5.0.0
2ba34a97b000-2ba34ab7a000 ---p 001fd000 fe:04 168033
  /usr/lib64/libgmx_d.so.5.0.0
2ba34ab7a000-2ba34ab7f000 r--p 001fc000 fe:04 168033
  /usr/lib64/libgmx_d.so.5.0.0
2ba34ab7f000-2ba34ab89000 rw-p 00201000 fe:04 168033
  /usr/lib64/libgmx_d.so.5.0.0
2ba34ab89000-2ba34ab8d000 rw-p 00000000 00:00 0
2ba34ab8d000-2ba34ac4c000 r-xp 00000000 fe:04 168027
  /usr/lib64/libmd_d.so.5.0.0
2ba34ac4c000-2ba34ae4c000 ---p 000bf000 fe:04 168027
  /usr/lib64/libmd_d.so.5.0.0
2ba34ae4c000-2ba34ae4d000 r--p 000bf000 fe:04 168027
  /usr/lib64/libmd_d.so.5.0.0
2ba34ae4d000-2ba34ae4f000 rw-p 000c0000 fe:04 168027
  /usr/lib64/libmd_d.so.5.0.0
2ba34ae4f000-2ba34af90000 r-xp 00000000 fe:04 2558
  /usr/lib64/libxml2.so.2.7.6
2ba34af90000-2ba34b18f000 ---p 00141000 fe:04 2558
  /usr/lib64/libxml2.so.2.7.6
2ba34b18f000-2ba34b197000 r--p 00140000 fe:04 2558
  /usr/lib64/libxml2.so.2.7.6
2ba34b197000-2ba34b199000 rw-p 00148000 fe:04 2558
  /usr/lib64/libxml2.so.2.7.6
2ba34b199000-2ba34b19b000 rw-p 00000000 00:00 0
2ba34b19b000-2ba34b376000 r-xp 00000000 fe:04 118370
  /usr/lib64/libgsl.so.0.14.0
2ba34b376000-2ba34b575000 ---p 001db000 fe:04 118370
  /usr/lib64/libgsl.so.0.14.0
2ba34b575000-2ba34b578000 r--p 001da000 fe:04 118370
  /usr/lib64/libgsl.so.0.14.0
2ba34b578000-2ba34b583000 rw-p 001dd000 fe:04 118370
  /usr/lib64/libgsl.so.0.14.0
2ba34b583000-2ba34b598000 r-xp 00000000 fe:02 8166
  /lib64/libnsl-2.11.so
2ba34b598000-2ba34b797000 ---p 00015000 fe:02 8166
  /lib64/libnsl-2.11.so
2ba34b797000-2ba34b798000 r--p 00014000 fe:02 8166
  /lib64/libnsl-2.11.so
2ba34b798000-2ba34b799000 rw-p 00015000 fe:02 8166
  /lib64/libnsl-2.11.so
2ba34b799000-2ba34b79b000 rw-p 00000000 00:00 0
2ba34b79b000-2ba34b90a000 r-xp 00000000 fe:04 182141
  /usr/lib64/libfftw3.so.3.2.4
2ba34b90a000-2ba34bb09000 ---p 0016f000 fe:04 182141
  /usr/lib64/libfftw3.so.3.2.4
2ba34bb09000-2ba34bb15000 r--p 0016e000 fe:04 182141
  /usr/lib64/libfftw3.so.3.2.4
2ba34bb15000-2ba34bb16000 rw-p 0017a000 fe:04 182141
  /usr/lib64/libfftw3.so.3.2.4
2ba34bb16000-2ba34bb17000 rw-p 00000000 00:00 0
2ba34bb17000-2ba34bb97000 r-xp 00000000 fe:02 8173
  /lib64/libm-2.11.so
2ba34bb97000-2ba34bd96000 ---p 00080000 fe:02 8173
  /lib64/libm-2.11.so
2ba34bd96000-2ba34bd97000 r--p 0007f000 fe:02 8173
  /lib64/libm-2.11.so
2ba34bd97000-2ba34bd98000 rw-p 00080000 fe:02 8173
  /lib64/libm-2.11.so
2ba34bd98000-2ba34bdb8000 r-xp 00000000 fe:04 141906
  /usr/lib64/blas/threaded-atlas/libblas.so.0.0.0
2ba34bdb8000-2ba34bfb7000 ---p 00020000 fe:04 141906
  /usr/lib64/blas/threaded-atlas/libblas.so.0.0.0
2ba34bfb7000-2ba34bfb8000 r--p 0001f000 fe:04 141906
  /usr/lib64/blas/threaded-atlas/libblas.so.0.0.0
2ba34bfb8000-2ba34bfb9000 rw-p 00020000 fe:04 141906
  /usr/lib64/blas/threaded-atlas/libblas.so.0.0.0
2ba34bfb9000-2ba34c44f000 r-xp 00000000 fe:04 177220
  /usr/lib64/lapack/atlas/liblapack.so.0.0.0
2ba34c44f000-2ba34c64e000 ---p 00496000 fe:04 177220
  /usr/lib64/lapack/atlas/liblapack.so.0.0.0
2ba34c64e000-2ba34c64f000 r--p 00495000 fe:04 177220
  /usr/lib64/lapack/atlas/liblapack.so.0.0.0Aborted


2010/2/19  <hess at sbc.su.se>:
> Hi,
>
> The gmx_genion.c code is correct (there might be memory leaks,
> but every Gromacs program has that problem).
> Your fix is surely incorrect, you leaving two open files open.
>
> Berk
>
>> Hi
>>
>> Here patch to fix double free memory coruption in gmx_genion.c
>>
>> --
>> Best Regards,
>> Alexey 'Alexxy' Shvetsov
>> Petersburg Nuclear Physics Institute, Russia
>> Department of Molecular and Radiation Biophysics
>> Gentoo Team Ru
>> Gentoo Linux Dev
>> mailto:alexxyum at gmail.com
>> mailto:alexxy at gentoo.org
>> mailto:alexxy at omrb.pnpi.spb.ru
>> --
>> gmx-developers mailing list
>> gmx-developers at gromacs.org
>> http://lists.gromacs.org/mailman/listinfo/gmx-developers
>> Please don't post (un)subscribe requests to the list. Use the
>> www interface or send it to gmx-developers-request at gromacs.org.
>
> --
> gmx-developers mailing list
> gmx-developers at gromacs.org
> http://lists.gromacs.org/mailman/listinfo/gmx-developers
> Please don't post (un)subscribe requests to the list. Use the
> www interface or send it to gmx-developers-request at gromacs.org.
>



-- 
Best Regards,
Alexey 'Alexxy' Shvetsov
Petersburg Nuclear Physics Institute, Russia
Department of Molecular and Radiation Biophysics
Gentoo Team Ru
Gentoo Linux Dev
mailto:alexxyum at gmail.com
mailto:alexxy at gentoo.org
mailto:alexxy at omrb.pnpi.spb.ru



More information about the gromacs.org_gmx-developers mailing list