[gmx-developers] Re: valgrind

hess at sbc.su.se hess at sbc.su.se
Fri Jul 2 10:41:14 CEST 2010


Hi,

Any variable that is accessed should be initialized.
I don't know if there are disadvantages to using {0}.
Valgrind often thinks (or used to think) arrays in structs
are unitialized when you initialize the struct with memset.
I don't know if that also happens with {0}.
But I guess you checked that this fixes the valgrind warning?

Berk

> Hi Berk,
>
> while I run valgrind I had a couple of errors (suppressing anything MPI
> related).
>
> Thus I have a couple of questions:
>
> What is our policy regarding uninitialized variables. Is it OK to leave
> them uninitialized if they are not used or should they always be
> initialized
> when they are indirectly used.
> Example:
> set_ddbox_cr doesn't set the members v or normal of ddbox (type
> gmx_ddbox_t)
> and then bcast. valgrind of course sees this as an error because the bcast
> reads the initialized variable.
>
> If they should always be initialized, is it a good idea to initialize
> static structs with "= {0}"? E.g. ddbox is declared in mdrunner as
>       gmx_ddbox_t ddbox;
> Should this be changed to:
>       gmx_ddbox_t ddbox={0};
> ?
>
> Or is there some reason not to use the "{0}" method to initialize? If the
> {0} is OK than just let me know and I'll commit it. I have fixed it in 2
> places.
>
> Do you have a valgrind suppression list with known false-positives?
>
> Some of the errors I've seen:
>
> ==2841== Invalid read of size 4
> ==2841==    at 0x538CE1: gmx_pme_send_q_x (pme_pp.c:202)
> ==2841==    by 0x538E60: gmx_pme_send_q (pme_pp.c:237)
> ==2841==    by 0x462273: dd_partition_system (domdec.c:8550)
> ==2841==    by 0x4308EA: do_md (md.c:1259)
> ==2841==    by 0x42C6F2: mdrunner (runner.c:771)
> ==2841==    by 0x4377CC: main (mdrun.c:631)
> ==2841==  Address 0x7feffc4cc is on thread 1's stack
>
> ==2846== Uninitialised byte(s) found during client check request
> ==2846==    at 0x625C09D: valgrind_module_isdefined (in
> /autofs/na1_home/z8g/sof
> tware/ompi-1.4.2/lib/libopen-pal.so.0.0.0)
> ==2846==    by 0x5D8547A: PMPI_Isend (in
> /autofs/na1_home/z8g/software/ompi-1.4.
> 2/lib/libmpi.so.0.0.2)
> ==2846==    by 0x539B50: gmx_pme_send_force_vir_ener (pme_pp.c:507)
> ==2846==    by 0x536F8F: gmx_pmeonly (pme.c:2423)
> ==2846==    by 0x42C75E: mdrunner (runner.c:792)
> ==2846==    by 0x4377CC: main (mdrun.c:631)
> ==2846==  Address 0x7feffceb0 is on thread 1's stack
>
> ==2846== Conditional jump or move depends on uninitialised value(s)
> ==2846==    at 0x42C7F7: mdrunner (runner.c:800)
> ==2846==    by 0x4377CC: main (mdrun.c:631)
> ==2846==
> ==2846== Conditional jump or move depends on uninitialised value(s)
> ==2846==    at 0x6B22760: __tzfile_compute (in /lib64/libc-2.5.so)
> ==2846==    by 0x6B221BE: __tz_convert (in /lib64/libc-2.5.so)
> ==2846==    by 0x6B20798: ctime (in /lib64/libc-2.5.so)
> ==2846==    by 0x54B9B1: print_date_and_time (sim_util.c:253)
> ==2846==    by 0x42C920: mdrunner (runner.c:821)
> ==2846==    by 0x4377CC: main (mdrun.c:631)
>
>
> Roland
>
> --
> ORNL/UT Center for Molecular Biophysics cmb.ornl.gov
> 865-241-1537, ORNL PO BOX 2008 MS6309
>




More information about the gromacs.org_gmx-developers mailing list